Locale settings
Edward K. Ream
edreamleo at charter.net
Wed Apr 23 16:49:35 EDT 2003
> Guess I can use the included version for awhile
> and then, once 2.3 become common, just tell users to use that python
> version.
No need. Try to use getpreferredencoding, and fall back to your copied
code. For example, after reading this thread I added a global
getpreferredencoding function to my app like this:
try:
# Use Python's version of getpreferredencoding if it exists.
# It is new in Python 2.3.
import locale
getpreferredencoding = locale.getpreferredencoding
except:
# Use code copied from locale.py in Python 2.3alpha2.
if sys.platform in ('win32', 'darwin', 'mac'):
<< define getpreferredencoding using _locale >>
else:
<< define getpreferredencoding for *nix >>
This code is at the top level of the module.
Edward
** Please note my new email address and Leo's new URL below **
--------------------------------------------------------------------
Edward K. Ream email: edreamleo at charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
More information about the Python-list
mailing list