wxPython / Mac / unicode
Diez B. Roggisch
deets at nospam.web.de
Wed Jan 4 12:45:30 EST 2006
isthar wrote:
> Hi!
> I can not present unicode string in wxPython application
>
> utf-8 string: SomeProductName®
>
> here is how I converted it from iso8859-18
> reference = unicode (reference,'iso8859_15').encode('utf-8')
>
> Traceback (most recent call last):
> File "/Users/isthar/Documents/Projects/pyEdipEditor/MainFrame.py",
> line 417, in OnSelectGen
> self.textRef.SetValue( reference )
> File
>
"/BinaryCache/wxWidgets/wxWidgets-2.root~174/System/Library/Frameworks/Python.framework/
> Versions/2.3/Extras/lib/python/wx-2.5.3-mac-unicode/wx/_controls.py",
> line 1638, in SetValue
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
> 25: ordinal not in range(128)
>
> As You see I have unicode version of wx ... so I am in dead end now.
>
> please, ... some clue ... :(
You are passing a string (encoded in utf-8), not a unicode-object. Thus wx
gets into trouble when trying to decode that string.
Instead of
reference = unicode (reference,'iso8859_15').encode('utf-8')
just do
reference = unicode (reference,'iso8859_15')
And before doing that, do:
for i in xrange(100):
print "UTF-8 is not unicode, its an encoding!"
:)
Regards,
Diez
More information about the Python-list
mailing list