[erlang-questions] io module encoding

Camille Troillard lists@REDACTED
Thu Jun 26 11:28:31 CEST 2014


On Mac OS X, when I start an Erlang shell from the command-line the io module encoding is set to unicode:

> Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
> Eshell V5.10.4  (abort with ^G)
> 1> os:getenv("LC_CTYPE").
> "UTF-8"
> 2> lists:keyfind(encoding, 1, io:getopts()).
> {encoding,unicode}

So that’s great.

Now, I have a GUI application that launches the Erlang shell. At first I thought the LC_CTYPE environment variable was not set (which was the case), but even when set to UTF-8, this does not work as expected:

Here's the output of the shell launched by the GUI application:

> 1> os:getenv("LC_CTYPE").
> "UTF-8"
> 2> lists:keyfind(encoding, 1, io:getopts()).
> {encoding,latin1}

I want {encoding, unicode}, and don’t understand why it defaults to latin1.
How can it be?

The documentation of io says:

> The standard shell will be set for either Unicode or latin1 encoding when the system is started. The actual encoding is set with the help of the LANG or LC_CTYPE environment variables on Unix-like system or by other means on other systems.

Does Mac OS X applies to “other systems”? If so, what are the “other means”?



More information about the erlang-questions mailing list