On macos, LC_CTYPE set to wrong value - where to change for iTerm2?

3

On my system, the locale variable LC_CTYPE is set to an illegal value, which causes issues on Linux systems. It's set to:

$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

LC_CTYPE=UTF-8 is not a legal value on Linux; eg.:

$ ssh front1
Linux front1 3.16.0-7-amd64 #1 SMP Debian 3.16.59-1 (2018-10-03) x86_64

The programs included with the Debian GNU/Linux system are free software;
…
alex@front1 ~> perl
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US").

But where does LC_CTYPE get set in the first place? It's not in any file in /etc or $HOME (I did a sudo fgrep -ri LC_CTYPE /etc $HOME).

I'm using iTerm2 as my terminal application.

Alexander Skwar

Posted 2019-01-31T08:06:34.507

Reputation: 191

Answers

3

After a bit of ddg, I came about the blog post Setting locales correctly on Mac OSX Terminal application on Remi Bergsma's blog. Turns out, also iTerm2 has such a setting. Disabling it, makes iTerm2 not mess up the locale.

iTerm2 Preferences -> Locale

Now it's set like this:

$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

Which isn't great either, as I've set my system to Swiss German. The normale terminal application is better in that respect:

$ locale
LANG="de_CH.UTF-8"
LC_COLLATE="de_CH.UTF-8"
LC_CTYPE="de_CH.UTF-8"
LC_MESSAGES="de_CH.UTF-8"
LC_MONETARY="de_CH.UTF-8"
LC_NUMERIC="de_CH.UTF-8"
LC_TIME="de_CH.UTF-8"
LC_ALL=

Alexander Skwar

Posted 2019-01-31T08:06:34.507

Reputation: 191