base64 and unicode

Duncan Booth duncan.booth at invalid.invalid
Fri May 4 09:03:55 EDT 2007


EuGeNe Van den Bulke <eugene.vandenbulke at gmail.com> wrote:

> Duncan Booth wrote:
>> However, the decoded text looks as though it is utf16 encoded so it
>> should be written as binary. i.e.  the output mode should be "wb".
> 
> Thanks for the "wb" tip that works (see bellow). I guess it is 
> experience based but how could you tell that it was utf16 encoded?

I pasted the encoded form into idle and decoded it base 64. It ends with \r
\x00\n\x00 and the nulls instantly suggest a 16 bit encoding. Scrolling to 
the beginning and it starts \xff\xfe which is the BOM for little-endian 
utf16.



More information about the Python-list mailing list