Slug: python-unicode-ascii-encodings Date: 2003-11-13 Title: Python, unicode, ascii, encodings layout: post

I've been working on a python-based app for a week or so now (on and off) and I've run into a spate of problems I don't know how to handle.

I'm getting RSS data in (I'm told) UTF-8 from the server. It's aggregated data, so there's no telling the source. Some of it is international (Japanese I think) and I'm having a crap time getting python to work with it. It oughta work, as I understand it, but all I get is:

UnicodeDecodeError: 'ascii' codec can't
decode byte 0xe2 in position 2: ordinal
not in range(128)

I've tried a few things with various encodings, but I'm not grokking something. Anyone with either text encoding or python experience have any ideas?

Oh, all I'm doing with it is pouring it into a template using <pre>UNICODE_TEMPLATE_TEXT % (mystery_text)</pre>