converting octal strings to unicode

Christos TZOTZIOY Georgiou tzot at
Fri Dec 24 13:11:31 CET 2004

On 23 Dec 2004 18:41:57 -0800, rumours say that flamingivanova at
might have written:

>I have several ascii files that contain '\ooo' strings which represent
>the octal value for a character. I want to convert these files to
>unicode, and I came up with the following script. But it seems to me
>that there must be a much simpler way to do it. Could someone more
>experienced suggest some improvements?

(hope I cancelled the previous off-by-one-backslash post...)

your_string = "\\326du"
decoded_string = your_string.decode("string_escape")
unicode_text = unicode(decoded_string, "latin-1")
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...

More information about the Python-list mailing list