mercurial/util.py
changeset 4540 133a52d70958
parent 4533 36abb07c79d4
child 4625 eaf87cd19337
--- a/mercurial/util.py	Mon Jun 11 11:06:42 2007 -0700
+++ b/mercurial/util.py	Mon Jun 11 12:14:31 2007 -0700
@@ -17,8 +17,15 @@
 import os, threading, time, calendar, ConfigParser, locale, glob
 
 try:
-    _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \
-                or "ascii"
+    _encoding = os.environ.get("HGENCODING")
+    if sys.platform == 'darwin' and not _encoding:
+        # On darwin, getpreferredencoding ignores the locale environment and
+        # always returns mac-roman. We override this if the environment is
+        # not C (has been customized by the user).
+        locale.setlocale(locale.LC_CTYPE, '')
+        _encoding = locale.getlocale()[1]
+    if not _encoding:
+        _encoding = locale.getpreferredencoding() or 'ascii'
 except locale.Error:
     _encoding = 'ascii'
 _encodingmode = os.environ.get("HGENCODINGMODE", "strict")