[wxPython-users] Re: OT Unicode, Locales and Python (for a wxPy app)

Werner F. Bruhin werner.bruhin at free.fr
Thu Dec 14 08:25:41 PST 2006


Hi Donn,

Donn Ingle wrote:
>> I am not sure how to change the encoding of the 
>> locale, so I can test other kinds. 
>>     
>
> Any hints? I'm on Kubuntu 6.06
>   
I do this in my app:

if hasattr(sys, "frozen"):  #Py2Exe does not run Site.py
    sys.setdefaultencoding('iso-8859-1')
else:                       #The Python interpreter needs to reload the 
function
    reload(sys)
    sys.setdefaultencoding('iso-8859-1')
    del sys.setdefaultencoding

Note that I am not using Unicode build (at least not yet) and my app is 
supporting English, German and French. 

I also needed to do this to ensure that the correct stuff was returned 
by e.g. 'letters', 'lowercase' and 'uppercase' (all string constants).

import locale
locale.setlocale(locale.LC_ALL, '')

Werner





More information about the wxpython-users mailing list