]> code.delx.au - gnu-emacs/commitdiff
Set locale encoding to UTF-8 when run from OS X GUI.
authorAlan Third <alan@idiocy.org>
Fri, 8 Apr 2016 13:52:55 +0000 (15:52 +0200)
committerAnders Lindgren <andlind@gmail.com>
Fri, 8 Apr 2016 13:52:55 +0000 (15:52 +0200)
* src/nsterm.m (ns_init_locale): Append .UTF-8 when setting LANG.

src/nsterm.m

index 4048ac465468e345e4fb55bb4e29b8371de16de2..34c5395b630d5a6f3f9650354b1530e7ce22d0da 100644 (file)
@@ -596,8 +596,15 @@ ns_init_locale (void)
 
   @try
     {
+      /* It seems OS X should probably use UTF-8 everywhere.
+         'localeIdentifier' does not specify the encoding, and I can't
+         find any way to get the OS to tell us which encoding to use,
+         so hard-code '.UTF-8'. */
+      NSString *localeID = [NSString stringWithFormat:@"%@.UTF-8",
+                                     [locale localeIdentifier]];
+
       /* Set LANG to locale, but not if LANG is already set. */
-      setenv("LANG", [[locale localeIdentifier] UTF8String], 0);
+      setenv("LANG", [localeID UTF8String], 0);
     }
   @catch (NSException *e)
     {