conversion to and from unicode strings

Duncan Booth duncan.booth at invalid.invalid
Mon Oct 27 12:58:33 CET 2008

abhishek <guptaabhishek1983 at> wrote:

> hello group,
>   i want to represent and store a string u'\x00\x07\xa7' as
> '\x00\x07\xa7'. any ideas on how to achieve this.

You can use latin-1 encoding.

>>> u = ''.join(unichr(c) for c in range(256))
>>> [ord(c) for c in u.encode('latin1')] == range(256)

Duncan Booth

More information about the Python-list mailing list