[wxPython-users] ANN: GUI2Exe for wxPython :-D
Robin Dunn
robin at alldunn.com
Wed Apr 4 14:34:07 PDT 2007
Andrea Gavana wrote:
>> And removed
>> wx.SetDefaultPyEncoding("utf-8")
>
> No, don't do that. If you encode everything using UTF-8, I can enter a
> project name like this:
>
> MyProject (some kind of french/german/russian/whatever non-ascii
> non-cp1252 letter)
>
> And, while the database will recognize them (because you are encoding
> them as UTF-8), the tree control on the left will not display the
> project names correctly, as wxPython will use
> wx.GetDefaultPyEncoding(), which returns the string encoding
> for the system at the moment. That means, if you send me your
> database, my tree control will probably display a bunch of squares
> instead of the names you have used (if you used hebrew letters, for
> example). I may be wrong here, so please everyone enlight me if I am
> saying stupid things.
Just for clarification, the wx.SetDefaultPyEncoding value only sets the
codec to be used when wxPython needs to convert to/from unicode/ansi for
wx methods and functions only. This value usually defaults to
locale.getpreferredencoding() so it matches what Python thinks is the
default for your system as it is currently configured. It doesn't have
any effect on any other automatic conversions or coercions that Python
will try to.
For example, if you have a Unicode build of wxPython, and pass a string
object to textctrl.SetValue, then it will use the
wx.GetDefaultPyEncoding() encoding to convert it to a Unicode object to
pass to the C++ SetValue. The opposite is also true, if you have an
ansi build of wxPython and pass a Unicode object then that encoding will
be used to convert it to a string first.
For other automatic ansi/unicode conversions that Python does then it
uses the return value of sys.getdefaultencoding() for the encoding.
Python also provides the sys.getfilesystemencoding() value which
specifies what should be used for encoding unicode values into ansi
strings to be used for path and file names on the current system.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list