Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 7461:2a67430f92f1 1.1
encoding: normalize some silly encoding names
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 02 Dec 2008 13:05:40 -0600 |
parents | f0a3e87c810d |
children | 5185a24ce04e 85dc88630beb |
comparison
equal
deleted
inserted
replaced
7460:3342e6ada4b9 | 7461:2a67430f92f1 |
---|---|
79 from popen2 import Popen3 | 79 from popen2 import Popen3 |
80 popen2 = os.popen2 | 80 popen2 = os.popen2 |
81 popen3 = os.popen3 | 81 popen3 = os.popen3 |
82 | 82 |
83 | 83 |
84 _encodingfixup = {'646': 'ascii', 'ANSI_X3.4-1968': 'ascii'} | |
85 | |
84 try: | 86 try: |
85 _encoding = os.environ.get("HGENCODING") | 87 _encoding = os.environ.get("HGENCODING") |
86 if sys.platform == 'darwin' and not _encoding: | 88 if sys.platform == 'darwin' and not _encoding: |
87 # On darwin, getpreferredencoding ignores the locale environment and | 89 # On darwin, getpreferredencoding ignores the locale environment and |
88 # always returns mac-roman. We override this if the environment is | 90 # always returns mac-roman. We override this if the environment is |
89 # not C (has been customized by the user). | 91 # not C (has been customized by the user). |
90 locale.setlocale(locale.LC_CTYPE, '') | 92 locale.setlocale(locale.LC_CTYPE, '') |
91 _encoding = locale.getlocale()[1] | 93 _encoding = locale.getlocale()[1] |
92 if not _encoding: | 94 if not _encoding: |
93 _encoding = locale.getpreferredencoding() or 'ascii' | 95 _encoding = locale.getpreferredencoding() or 'ascii' |
96 _encoding = _encodingfixup.get(_encoding, _encoding) | |
94 except locale.Error: | 97 except locale.Error: |
95 _encoding = 'ascii' | 98 _encoding = 'ascii' |
96 _encodingmode = os.environ.get("HGENCODINGMODE", "strict") | 99 _encodingmode = os.environ.get("HGENCODINGMODE", "strict") |
97 _fallbackencoding = 'ISO-8859-1' | 100 _fallbackencoding = 'ISO-8859-1' |
98 | 101 |