Mercurial > public > mercurial-scm > hg
comparison mercurial/encoding.py @ 9574:9e9f63d5c456
encoding: fix issue with non-standard UTF-8 CTYPE on OS X
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sat, 10 Oct 2009 12:00:43 +0200 |
parents | b87a50b7125c |
children | 25e572394f5c |
comparison
equal
deleted
inserted
replaced
9573:b8352a3617f3 | 9574:9e9f63d5c456 |
---|---|
14 encoding = os.environ.get("HGENCODING") | 14 encoding = os.environ.get("HGENCODING") |
15 if sys.platform == 'darwin' and not encoding: | 15 if sys.platform == 'darwin' and not encoding: |
16 # On darwin, getpreferredencoding ignores the locale environment and | 16 # On darwin, getpreferredencoding ignores the locale environment and |
17 # always returns mac-roman. We override this if the environment is | 17 # always returns mac-roman. We override this if the environment is |
18 # not C (has been customized by the user). | 18 # not C (has been customized by the user). |
19 locale.setlocale(locale.LC_CTYPE, '') | 19 lc = locale.setlocale(locale.LC_CTYPE, '') |
20 if lc == 'UTF-8': | |
21 locale.setlocale(locale.LC_CTYPE, 'en_US.UTF-8') | |
20 encoding = locale.getlocale()[1] | 22 encoding = locale.getlocale()[1] |
21 if not encoding: | 23 if not encoding: |
22 encoding = locale.getpreferredencoding() or 'ascii' | 24 encoding = locale.getpreferredencoding() or 'ascii' |
23 encoding = _encodingfixup.get(encoding, encoding) | 25 encoding = _encodingfixup.get(encoding, encoding) |
24 except locale.Error: | 26 except locale.Error: |