wxPython / Mac / unicode

I

isthar

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 ... :(

gr, tomek
 
D

Diez B. Roggisch

isthar said:
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
 
I

isthar

Hi

I did your loop after ensuring that everything works fine:p
Big Thanks :D

Greets,

Tomek.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Unicode confusion 0
wxpython 5
Py3: Read file with Unicode characters 4
Thinking Unicode 0
Unicode error 19
Python dict as unicode 1
printing unicode strings 3
Python 3.3, gettext and Unicode problems 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top