Help with unicode and sqlobject/pysqlite2

Gerhard Häring gh at ghaering.de
Wed Sep 28 04:59:39 EDT 2005


qvx wrote:
> I really can't seem to make sqlobject/pysqlite2 save my local Easter
> European characters.
> 
> I am a Windows-1250 user and I have sys.setdefaultencoding('dbcs') in
> my sitecustomize.
> 
> How can I save data like "šdccž"?
> This is equivalent to '\x9a\xf0\xe8\xe6\x9e'
> 
> I'm using the latest version of sqlobject from SVN.

I can't speak for SQLObject (yet), but if you want to insert text data 
using pysqlite, you have to either encode them to UTF-8 or use unicode 
strings.

You can convert to unicode strings using
unicode('\x9a\xf0\xe8\xe6\x9e', 'dbcs'). As your system default encoding 
is 'dbcs', even unicode('\x9a\xf0\xe8\xe6\x9e') would be enough.

HTH,

-- Gerhard




More information about the Python-list mailing list