Subject: Re: bug#22392: 25.0.50; NS Emacs run from OS X GUI doesn't set locale

From: Random832 <[email-masked]>
Date: Mon, 18 Jan 2016 17:09:02 -0500

On Mon, Jan 18, 2016, at 16:12, Alan Third wrote:
> I don't know if it's appropriate for OS X, but I'm pretty sure it
> matches the codings that the Windows port gives me for en_GB (ENG, in
> Windows). Besides, surely it's better than 'nil'?

Well, I don't have any trouble opening UTF-8 files. I'm incidentally not
sure that it's really appropriate for windows, either - there, it should
be using windows-1252, not iso-latin-1. I have to wonder how Emacs
behaves on versions of windows whose default codepage is not a trivial
superset of an ISO one. The proper encoding should be able to be
determined by the GetACP function, and should always be a windows
codepage.

> > How does Terminal (and iTerm) know to use UTF-8?
> 
> If you load Emacs on OS X from the terminal this code changes some
> settings (set-locale-environment in mule-cmds.el):

I meant Terminal itself, not Emacs within terminal. For me, it seems to
put LANG=en_US.UTF-8 in the environment.

> The other possibility is that Terminal.app sets LANG to 'en_GB.UTF-8'.
> That final part may be the difference we're seeing here?

Yes, I think so. I was wondering also if there's some hidden setting
that tells Terminal whether to use UTF-8 or not - I don't think it used
it in the earliest versions of OSX.

> > This one also makes me wonder if the encoding specified in
> > .CFUserTextEncoding/__CF_USER_TEXT_ENCODING should be used for a second
> > choice. Which may be an encoding that may not map directly to a locale.
> 
> I'm afriad I don't know what you're talking about here.

You may have a file .CFUserTextEncoding in your home directory, or an
environment variable __CF_USER_TEXT_ENCODING, specifying a value like
[0x1F5:]0x0:0x0 - the first one (in the environment variable only) is
your user ID, the next is the encoding (0x0 for MacRoman) which Finder
uses for preview of non-UTF8 text files, and the last is the language (0
for English, maybe only US English)

For me this is MacRoman (and works as I described with Finder preview
windows) even though there is no actual Unix locale for MacRoman.