[PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

Boudewijn Rempt boud at rempt.xs4all.nl
Tue Dec 7 19:11:15 GMT 1999

On Tue, 7 Dec 1999, Richard Jones wrote:

> > 
> > I can very easily revert the Qt v1.x behavior to what it was in earlier
> > versions, but the Qt v2.x behavior will be done like this in order to
> > support Unicode. The disadvantage of mixing the two approaches is that
> > scripts won't be portable between the two.  What's the consensus?
>    I'd be interested to know what the general Python approach to Unicode is. I 
> guess it'd be nice to just seamlessly move from python 1.5 & Qt 1.x to python 
> 1.6 & Qt 2.x with no buggering around with repr() ;)
>    I've just had a poke around, but couldn't find any concrete information on 
> how Unicode in Python is going...

I personally really liked the old approach of mapping QString to Python
strings - but I see the problem, of course. There's not much to choose
between repr and str - one idea that appeals to me, is to extend the 
Python version of the QString object with a toPyString function, and
have that return the QString in the current encoding. 

Unicode in Python is currently a bit of a mess - there are several third
party modules that offer wrappers to C wstring - and people are actively
working on getting Unicode to work in 1.6. Most of the advances seem to
come from the work on XML support - you get one of those Unicode modules
when you install the current XML beta. 

Of course, since Python strings are 8-bit clean you can just as easily
store Unicode data in them (in fact, you can store any binary data in
them - although I don't know whether you can embed null characters in
Python strings): the problem is that the standard string handling modules
don't know what to do.

What I'm wondering at is, how are we going to get the unmangled 16 (or
32 bit) Unicode data from the QString object? I'd like to save the
stuff in a file (for instance, for XML processing), or store it in the
database. Actual string processing in Python is relatively unimportant,
compared to that.

Perhaps it would be neat to have QString.latin1(), QString.utf8(),
QString.local8bit() and QString.unicode() return a Python string - with
the bytes in the chosen encoding, as an equivalent of the array of QChars.
Could be combined with a repr which returns the QString in the current

Anyway, all encodings are a mess, and have been ever since I first
tried to work with the ZX-Spectrum character set - I can't wait until
the world has become Unicode-only.

Boudewijn Rempt  | http://denden.conlang.org

More information about the PyQt mailing list