conversion to and from unicode strings

Duncan Booth duncan.booth at invalid.invalid
Mon Oct 27 07:58:33 EDT 2008


abhishek <guptaabhishek1983 at gmail.com> 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)
True


-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list