quick unicode Q

Heiko Wundram modelnine at bit-bukket.org
Wed Dec 14 19:54:03 EST 2005


Erik Max Francis wrote:
> Read it as a string, and then decode it with the .decode method.  You
> specify what encoding it's in.

Most probably, the OP is asking what to do with an UTF-8 encoded string.

To decode that, just use:

s.decode("utf-8")

to get a unicode string object.

Example:

>>> s
'\xc3\xa4\xc3\xb6\xc3\xbc'
>>> print s
ÀöÌ
>>> print s.decode("utf-8")
äöü
>>>

HTH!

--- Heiko.



More information about the Python-list mailing list