mercurial/encoding.py
changeset 9574 9e9f63d5c456
parent 8312 b87a50b7125c
child 10263 25e572394f5c
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: