Strange problems with encoding

Rudy Schockaert rudy.schockaert at pandoraSTOPSPAM.be
Thu Nov 6 16:03:01 CET 2003


> 
>>>>u'ö'.encode('utf-8').encode('base64')
> 
> 'w7Y=\n'

This works indeed. And thanks to Joe Fromm's hint (site.py) I don't have 
to worry about it anymore.
> 
> What would you like to do with a character that isn't in latin-1?
> 
Actually, I don't care as long as the encode and decode on the same 
machine give me back the original value.
> 
>>The reason I want to base64-encode these unicode strings is because I
>>get those as input and want to store them in a MySQL database using
>>SQLObject.
> 
> 
> ! Why can't you just encode them as utf-8 strings?  (Or, thinking
> about it, why doesn't SQLObject support unicode?)
> 

The actual input strings don't really contain unicode text values, but 
rather binary values i get as result from calling win32.NetUserEnum.

The manual of SQLObject (great product btw) explains how you can easily 
store binary data in a SQL table by encoding it when setting and 
decoding it  when getting the value. Tha is just what I was trying to do.




More information about the Python-list mailing list