From f6497c6e760b3b50015f35d7ce5a36df628ee498 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Fri, 8 Apr 2016 15:52:55 +0200 Subject: [PATCH] Set locale encoding to UTF-8 when run from OS X GUI. * src/nsterm.m (ns_init_locale): Append .UTF-8 when setting LANG. --- src/nsterm.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nsterm.m b/src/nsterm.m index 4048ac4654..34c5395b63 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -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) { -- 2.39.2