diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2003-03-03 09:34:01 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2003-03-03 09:34:01 (GMT) |
commit | 4eab486476c0082087a8460a5ab1064e64cc1a6b (patch) | |
tree | a64e7c5a38e4e006d578566dabd45373c86a9001 | |
parent | ad428cd1cd3f9d3f9a85da558e1225b4558a4f9b (diff) | |
download | cpython-4eab486476c0082087a8460a5ab1064e64cc1a6b.zip cpython-4eab486476c0082087a8460a5ab1064e64cc1a6b.tar.gz cpython-4eab486476c0082087a8460a5ab1064e64cc1a6b.tar.bz2 |
Patch #671666: Alias ANSI code page to "mbcs".
-rw-r--r-- | Lib/site.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/site.py b/Lib/site.py index 0ab7a0f..d74609a 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -282,6 +282,22 @@ class _Helper: __builtin__.help = _Helper() +# On Windows, some default encodings are not provided +# by Python (e.g. "cp932" in Japanese locale), while they +# are always available as "mbcs" in each locale. +# Make them usable by aliasing to "mbcs" in such a case. + +if sys.platform == 'win32': + import locale, codecs + enc = locale.getdefaultlocale()[1] + if enc.startswith('cp'): # "cp***" ? + try: + codecs.lookup(enc) + except LookupError: + import encodings + encodings._cache[enc] = encodings._unknown + encodings.aliases.aliases[enc] = 'mbcs' + # Set the string encoding used by the Unicode implementation. The # default is 'ascii', but if you're willing to experiment, you can # change this. |