[wxPython-users] 2.7 And Unicode Questions
Kevin Ollivier
kevino at tulane.edu
Fri Aug 11 14:35:53 PDT 2006
Hi Andrea,
On Aug 11, 2006, at 1:31 PM, Andrea Gavana wrote:
> Hello NG,
>
> I'm still using 2.6.3.3 at the moment, and I am thinking about
> switching to 2.7 pre-release in the near future (I hope). In the
> meanwhile, I would also try to switch to Python 2.5, if I can find all
> the dependencies updates for Python 2.5 (Numpy, py2exe, Pythonwin and
> so on). I obviously have to forget VTK :-D
>
> BTW, I have a couple of questions:
>
> 1) Is there anyone using 2.7 with Python 2.5 that can please share
> some comments about it? Did you encounter any problem?
>
> 2) As with other versions when they first came out, 2.7 broke PyAUI.
> It doesn't work anymore. I know, I know, PyAUI is dead, I should use
> the wrapped wx.aui from wxPython. However, the development version of
> PyAUI has some nice whistles and bells that I would have liked to
> keep. But I can live with wx.aui without problems :-D
>
> 3) Unicode: well, it seems to me that ANSI versions of wxPython have
> to be forgotten. Ok, have anyone encountered problems in using Unicode
> versions in place of ANSI? I know absolutely *nothing* about unicode,
> and doing a lot of I/O operations in my apps, I could end up in
> rewriting big parts of code.
It really depends on the case. If you're dealing only with ANSI/ascii
data, there's really not much to be concerned about. Issues mainly
arise when you have non-ascii/ANSI characters and need to load/save
data, because wxPython will convert data to Unicode behind the scenes
whenever you do a Set, etc. and you can't save non-ANSI Unicode text
to disk "as-is" - you'll need to convert it to utf-8 or some other
encoding. Also note that when you do u"My unicode text" + "My non-
unicode text", the "My non-unicode text" string gets 'up-converted'
to Unicode using the default locale, and will raise an error if it
couldn't convert all the characters successfully. Sometimes this
behavior is just fine, and won't require any/many changes for an app
to work, but other times, you need more control over the process. For
example, consider saving a file on one computer, and loading it on
another (with a different default locale). The default locale will
not match the encoding used for the data, so characters will not be
converted or converted incorrectly, and you have garbled text.
However, to be clear, that only applies to reading/writing to disk -
i.e. persistent data and external data formats. Usually, wxPython
deals with things correctly when sending text back and forth between
wxPython and Python. You're more likely to run into the annoying
problem where the Python "default encoding" is set to ascii, even
when the OS locale is not ascii, and in fact might be Unicode-
aware. ;-/ wxPython (IIRC) uses the OS encoding, but you may have
problems again when doing a myPythonString + myWxPythonString where
myPythonString contains non-ascii chars.
In any case, the transition is usually quite manageable. Usually, the
biggest hurdle is the initial learning curve of becoming aware of
encodings and why they're important, and finding out in what areas of
your app they are important. ;-) Hopefully this was more helpful than
confusing! ;-P
Regards,
Kevin
> Thank you very much for any hint.
>
> Andrea.
>
>
> --
> "Imagination Is The Only Weapon In The War Against Reality."
>
> http://xoomer.virgilio.it/infinity77/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-
> help at lists.wxwidgets.org
>
More information about the wxpython-users
mailing list