I've got a TextCtrl in a project and would like to properly display
UTF-8 characters. Is it possible to do this? Currently, I get an
error when I pass in a UTF-8 encoded string. It throws this
exception:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position
887: ordinal not in range(128)
Thanks for any help,
Isaac
First, you need to make sure that you have a unicode build of wxPython
('unicode' in wx.PlatformInfo).
Then you need to take your Python string which is a UTF-8 encoded
sequence of bytes, and create a python unicode object from it.
bytes = 'Some string with UTF-8 in it'
unicode_value = bytes.decode('utf-8')
Then pass the unicode object to the wxTextCtrl.
···
On 6/12/07, Isaac Wagner <isaac@wagnerfam.com> wrote:
I've got a TextCtrl in a project and would like to properly display
UTF-8 characters. Is it possible to do this? Currently, I get an
error when I pass in a UTF-8 encoded string. It throws this
exception:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position
887: ordinal not in range(128)
Thank you! That's exactly what I needed.
···
On 6/12/07, Chris Mellon <arkanes@gmail.com> wrote:
On 6/12/07, Isaac Wagner <isaac@wagnerfam.com> wrote:
> I've got a TextCtrl in a project and would like to properly display
> UTF-8 characters. Is it possible to do this? Currently, I get an
> error when I pass in a UTF-8 encoded string. It throws this
> exception:
>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position
> 887: ordinal not in range(128)
>
First, you need to make sure that you have a unicode build of wxPython
('unicode' in wx.PlatformInfo).
Then you need to take your Python string which is a UTF-8 encoded
sequence of bytes, and create a python unicode object from it.
bytes = 'Some string with UTF-8 in it'
unicode_value = bytes.decode('utf-8')
Then pass the unicode object to the wxTextCtrl.
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org