Re: decode unicode string using 'unicode_escape' codecs

2006-01-13 Thread Steven Bethard
aurora wrote: I have some unicode string with some characters encode using python notation like '\n' for LF. I need to convert that to the actual LF character. There is a 'unicode_escape' codec that seems to suit my purpose. encoded = u'A\\nA' decoded = encoded.decode('unicode_escape')

Re: decode unicode string using 'unicode_escape' codecs

2006-01-13 Thread aurora
Cool, it works! I have also done some due diligence that the utf-8 encoding would not introduce any Python escape accidentially. I have written a recipe in the Python cookbook: Efficient character escapes decoding http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466293 wy Does this

decode unicode string using 'unicode_escape' codecs

2006-01-12 Thread aurora
I have some unicode string with some characters encode using python notation like '\n' for LF. I need to convert that to the actual LF character. There is a 'unicode_escape' codec that seems to suit my purpose. encoded = u'A\\nA' decoded = encoded.decode('unicode_escape') print