[PyKDE] unicode two-way conversion

Hans-Peter Jansen hpj at urpla.net
Tue Oct 25 13:06:37 BST 2005


Am Dienstag, 25. Oktober 2005 12:48 schrieb Sebastian Kügler:
> On Tuesday 25 October 2005 12:28, Mateusz Korniak wrote:
> >
> > Encode to (and back from) utf-8.
> > Remember only that utf-8 representation is longer than number of
> > chars in unicode string if any non 7bit ascii char is used.
> > Also make sure that Yours DB iface allows to use 8bit encoding
> > (like iso-8859-1/2).
>
>   File "john.py", line 154, in dataFromGuiToUser
>     self.user.data["achternaam"] =
> self.GAchternaam.text().encode('utf-8', 'strict')
> AttributeError: encode
>
> So the problem is that I'm not able to convert the QString to utf-8
> (without making it a str first, which bails out on
> UnicodeDecodeError. See attached snippet.

Consider using QString.utf8() method.

Pete




More information about the PyQt mailing list