diff --git a/wxPython/docs/CHANGES.txt b/wxPython/docs/CHANGES.txt index aa4dead247..8626852476 100644 --- a/wxPython/docs/CHANGES.txt +++ b/wxPython/docs/CHANGES.txt @@ -133,6 +133,18 @@ morbidly curious, here are a few more details: value using str() or to the long integer value of the pointer using long(). +Added SetDefaultPyEncoding and GetDefaultPyEncoding functions which +will set/get the encoding used by wxPython to convert string or +unicode objects to/from wxString objects. Previously the default +Python encoding was always used, but unless the user had tweaked their +sitecustomize.py file it is always "ascii", which would result in +errors if the strings contained character codes >= 128. +SetDefaultPyEncoding will now allow you to control which encoding will +be used to do those conversions. The default encoding is set to the +value of `locale.getdefaultlocale()[1]` when wxPython is first +imported. Please see http://www.alanwood.net/demos/charsetdiffs.html +for subtle differences between the common latin/roman encodings. + diff --git a/wxPython/src/_app.i b/wxPython/src/_app.i index 3285fef3db..5628f0242b 100644 --- a/wxPython/src/_app.i +++ b/wxPython/src/_app.i @@ -361,7 +361,13 @@ DocDeclAStr( void , wxSetDefaultPyEncoding(const char* encoding), "SetDefaultPyEncoding(string encoding)", "Sets the encoding that wxPython will use when it needs to convert a -Python string or unicode object to or from a wxString.", ""); +Python string or unicode object to or from a wxString. + +The default encoding is the value of ``locale.getdefaultlocale()[1]`` +but please be aware that the default encoding within the same locale +may be slightly different on different platforms. For example, please +see http://www.alanwood.net/demos/charsetdiffs.html for differences +between the common latin/roman encodings.", ""); DocDeclAStr( const char* , wxGetDefaultPyEncoding(), diff --git a/wxPython/src/_core_ex.py b/wxPython/src/_core_ex.py index 702e04f6ee..656a54a991 100644 --- a/wxPython/src/_core_ex.py +++ b/wxPython/src/_core_ex.py @@ -32,7 +32,13 @@ if RELEASE_VERSION != _core_.RELEASE_VERSION: #---------------------------------------------------------------------------- -# Set the default string conversion encoding from the locale +# Set the default string<-->unicode conversion encoding from the +# locale. This encoding is used when string or unicode objects need +# to be converted in order to pass them to wxWidgets. Please be aware +# that the default encoding within the same locale may be slightly +# different on different platforms. For example, please see +# http://www.alanwood.net/demos/charsetdiffs.html for differences +# between the common latin/roman encodings. import locale default = locale.getdefaultlocale()[1] if default: