On Thu, 24 Apr 2003 17:47:29 +0200 Petr Vaněk wrote: > hello. > > how do you convert the qstring into python one? > str(qstring) works fine just for ascii/latin1 > something like > ret = unicode(str(qstring.local8Bit()), "utf-8") > raises > UnicodeError: UTF-8 decoding error: unexpected code byte > > headache today :-/ > If you have installed Eric, there is a file site-customize.py: [packer@venus python2.2]$ less /usr/lib/python2.2/site-packages/sitecustomize.py # # sitecustomize.py - saving a useful function. # generated by the eric install script # import sys sys.setappdefaultencoding = sys.setdefaultencoding # end of file So, from Python you can do: [packer@venus python2.2]$ python Python 2.2.2 (#1, Oct 23 2002, 12:12:09) [GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386 Type "help", "copyright", "credits" or "license" for more information. >>> from qt import *; import sys >>> str(QString(u'\u0411\u0412')) Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII encoding error: ordinal not in range(128) >>> sys.setappdefaultencoding('utf-8') >>> str(QString(u'\u0411\u0412')) '\xd0\x91\xd0\x92' >>> unicode(QString(u'\u0411\u0412')) u'\u0411\u0412' >>> Hope this makes your headache disappear, Gerard _______________________________________________ PyKDE mailing list PyKDE@mats.gmd.de http://mats.gmd.de/mailman/listinfo/pykde