Problems when converting from QString to str

teo teo at crepido.com
Wed Jul 25 06:36:49 EDT 2001


if i try to convert a Qstring (Qt 2.3.3) containing 'å'-'ä' or 'ö' to
python str i get the following error:


self.Comment contains u'testing å ä ö' 

code:

comment_text = str(self.Comment.text())
  
error:

File "MyPreferencesDevice.py", line 469, in slotOK
comment_text = str(self.Comment.text())
File "/usr/local/lib/python2.1/site-packages/qt.py", line 965, in
__str__
return str(self.sipThis)
UnicodeError: ASCII encoding error: ordinal not in range(128)

Does this mean I actually can't handle 'åäö' in my application or is
my code wierd?



More information about the Python-list mailing list