[PyKDE] Problem with German characters

Jim Bublitz jbublitz at nwinternet.com
Tue Oct 15 22:07:29 BST 2002

On 15-Oct-02 jblazi wrote:
> On Tuesday 15 October 2002 20:57, david wrote:
>> > Then I get the next problem. Here is my code:

>> > string.split(unicode(self.widget.text.eingabe.text()),'\n')
>> >     tmp = unicode(self.widget.text.eingabe.text())+'\n'

>> >     try:
>> >         exec tmp in user_name_space
>> >     except:
>> >         txt = str(sys.exc_info()[1])
>> >         return

>> > Here I get the error message

>> >  ASCII encoding error: ordinal not in range(128)
>> I'm using this :
>> blah = textedit.text().latin1()

>> It works fine.

> It doe not work for me; I get the same error message as above.
> (This seems to be no Python problem, as exec('a="ö"') works.

I'm not at all clear on what your code is trying to do, but if
".text()" is Qt code, it almost invariably returns a QString,
therefore you should need latin1(), utf8() or something similar from
QString to return an actual character string before using it with
any Python functions.

Your Python example would work because you're not passing exec a
QString. Maybe try a "print tmp" before the exec call and see what
string is actually being passed in tmp, or print the result of
*.text() and see what it returns. I don't think you should need
unicode for o-umlaut, but I'm far from being knowledgeable about
this stuff.


More information about the PyQt mailing list