On pages 29-30 of “Programming Erlang” by Joe Armstrong, the author goes over character strings. Erlang uses Latin-1 as it’s character set. At first, Terminal.app wasn’t showing the non-US / ASCII characters.
There’s a two-step process to solve this:
- Terminal->Window Settings…->Display->”Character Set Encoding” set to “Western (ISO Latin 1)”
- Set the environment variable LC_ALL to “en_US” before you run
erl. Also, see the next paragraph for explanations.
The above steps are for U.S. English — something similar is available for most locales, but I don’t know the specifics. Of note, is the 2nd step; firstly, LC_CTYPE is the specific value to set, but LC_ALL sets LC_* to the assigned value, so one usually wants LC_ALL, unless you have a very unique locale configuration. Secondly, I’m using Gentoo Prefix Portage environment on OSX, so while I feel that these directions are applicable to most OSX installs, my setup is slightly different, so your mileage may vary. Thirdly, for those that need UTF-8, they can set LC_ALL to “en_US.UTF-8″, and then they only have to toggle Terminal.app’s character set encoding. Why en_US.UTF-8 works, I do not know — Latin 1 is not a subset of UTF-8, so I’ll leave that to more inquiring minds.
After you find settings that you are happy with, consider adding export LC_ALL="en_US.UTF-8" to your ~/.bash_profile if you’d like it to load with every terminal window that opens. My ~/.bash_profile sources my ~/.bashrc, because ~/.bashrc is supposed to be safe for scripts that run as your user, but non-interactively; so, ~/.bash_profile tends to get a lot of my environment look and feel code.


Post a Comment