Subject: bug#3221: 23.0.93; ns cannot handle nonascii file names

From: Alan J Third <[email-masked]>
Date: Sat, 16 Jan 2016 17:06:17 +0000

Adrian Robert <[email-masked]> writes:

> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3221
>
> Hi,
>
>> After some investigation with Ian's help, I have found a workaround by
>> setting the language environment to UTF-8.
>>
>> The bug seems to be that Emacs.app is completely unaware of the
>> language
>> setting of OS X.
>
>
> I'd like to fix this.
>
> Do you know why it works from terminal?  Is there some code in emacs
> that reads the LANG or some other env setting and sets something in
> emacs?  Where?  What is the command to set the language environment?

OS X's terminal application sets the LANG environment variable, so when
Emacs is run from there it picks up LANG. When run from the GUI (dock,
or spotlight or whatever) OS X does *not* set the LANG variable, so
Emacs doesn't pick it up.

> While the various methods on the net to set up
> ~/.MacOSX/environment.plist might work, there ought to be some Cocoa
> way to detect language setting directly...

It looks like the right way to get the locale from OS X is something
like:

const char * locale = [[[NSLocale currentLocale] localeIdentifier] UTF8String];

HOWEVER, it appears the actual bug reported:

> 2. start Emacs from Finder
> 
> 3. M-! touch 求助.txt
> 
> No 求助.txt will be created instead, a file named .txt is created.

is fixed in emacs 25. Or, at least, I can't reproduce it.

Not having LANG set does break ispell checking with hunspell on OSX, for
me at least, so it would still be nice to have the locale stuff fixed.
Presumably there are other reasons for wanting Emacs to have the correct
locale, too.

Should that be a new bug report?
-- 
Alan Third