Can I get the 8bit-string representation of any unicode string
wanghz at gmail.com
wanghz at gmail.com
Sun Feb 12 13:54:03 EST 2006
Hi,
I see. Thank you for your help!
Regards,
hongzheng
Fredrik Lundh wrote:
> 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