Can I get the 8bit-string representation of any unicode string
Fredrik Lundh
fredrik at pythonware.com
Sun Feb 12 11:30:35 EST 2006
wanghz at gmail.com wrote
> I may misunderstood it. I will think about it carefully.
>
> By the way, does python has a interface, just like iconv in libc for
> C/C++? Or, how can I convert a string from a encoding into another
> one?
if b is an 8-bit string containing an encoded unicode string,
u = b.decode(encoding)
or
u = unicode(b, encoding)
gives you a unicode string. to encode the unicode string back to another
byte string, use the encode method.
b = u.encode(encoding)
</F>
More information about the Python-list
mailing list