[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyKDE] unicode two-way conversion
From: "Diez B. Roggisch" <deets () web ! de>
Date: 2005-10-25 12:39:46
Message-ID: 200510251439.46654.deets () web ! de
[Download RAW message or body]
> Ah, that helps the problem in my test script. Now I'm encountering a
> problem encoding the input of a QLineedit:
>
> File "john.py", line 154, in dataFromGuiToUser
> self.user.data["achternaam"] = self.GAchternaam.text().encode('utf-8',
> 'strict')
> AttributeError: encode
text() returns a QString, which you should look up in the qt-reference-manual.
That reveals the method
QString::utf8()
which returns a QCString. And that should be converted to a python byte string
(by means of sip I think)
Then you need to _decode_ it as utf-8 to yield a unicode object. So the whole
line should read
self.user.data["achternaam"] = self.GAchternaam.text().utf8().decode('utf-8')
Regards,
Diez
_______________________________________________
PyKDE mailing list PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic