[PyKDE] Python Unicode Objects and Qt Unicode strings
Boudewijn Rempt
bsarempt at rempt.xs4all.nl
Sat Dec 16 23:56:41 GMT 2000
On Sat, 16 Dec 2000, dan wrote:
> This doesn't work, but it may be a step in the right direction (I bet you've
> tried this)
> QString has a method called utf8()
> if I use your code to print out the python unicode string, then print out the
> QString using its method utf8() I get identical output
> e.g.
> print psu.encode('utf-8')
> print qsu.utf8()
>
That works - what QString.utf8() creates is a QCString, but it still
doesn't become a Python string or Unicode object, so you still can't
do anything useful with it (like converting it to hex representation
and storing in MySQL - I guess it's time to move to Postgress, which
should be able to store Unicode....).
> same (gross :) output
>
Depends on your terminal - if you use XFree 4.0.1 with its X term, and the
unicode fixed font, then you'll see the complete set of IPA extra
characters ;-).
> I'm interested in the solution to this problem (because any second I'll be
> using unicode in my project too)
>
> good luck (and, if possible, keep me informed)
> Dan
>
The one solution, that solves everything, is to hack ../lib/python/site.py
and replace the defaultcodec with utf-8... But that's a bit difficult for
applications intended to be used by third persons.
More information about the PyQt
mailing list