I'm migrating an application to the latest wxPython version.
By incident I got the Unicode version which complains when I use ListCtrl's SetStringItem() method because the string contains an accented character (not in range(128)). The non-Unicode version doesn't complain and shows the correct character.
My questions:
- Is this how it is supposed to be?
- How can I make it work on both Unicode and non-Unicode?
I'm still puzzled, as I only have errors on accented characters in a ListCrtl w/Unicode.
The same string goes without a problem into a StaticText.
--eric
···
On 19-aug-04, at 22:45, Eric Nieuwland wrote:
I'm migrating an application to the latest wxPython version.
By incident I got the Unicode version which complains when I use ListCtrl's SetStringItem() method because the string contains an accented character (not in range(128)). The non-Unicode version doesn't complain and shows the correct character.
My questions:
- Is this how it is supposed to be?
- How can I make it work on both Unicode and non-Unicode?
I'm migrating an application to the latest wxPython version.
By incident I got the Unicode version which complains when I use ListCtrl's SetStringItem() method because the string contains an accented character (not in range(128)). The non-Unicode version doesn't complain and shows the correct character.
My questions:
- Is this how it is supposed to be?
Yes. In the unicode builds the default Python encoding is used to convert strings to unicode objects whenever a wxString is expected by the C++ code. Since your default encoding is probably 'ascii' then it fails.
- How can I make it work on both Unicode and non-Unicode?
There are some options:
* Change the default encoding for your python.
* Pass all strings through a function that does something like this pseudo code:
if obj type is string and 'unicode' in wx.PlatformInfo:
obj = decode to unicode object with some appropriate encoding
return obj
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!