Thursday, January 23, 2014

Setting the locale in UNIX environment

Recently I upgraded from OS X 10.8 (Mountain Lion) to 10.9 (Mavericks), and noticed that my locale is set to (you can check this with command "locale"):

LANG="C"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C"

You'll experience some encoding problems with this locale. Also when you want to remote login to a Redhat machine, you'll encounter some warning. To set the locale to your preferred one (for me its "en_US.UTF-8"), you'll need to add these two lines in your ~/.bash_profile file:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

That's all, now you can open a new session (or just use this command within the running session: "source ~/.bash_profile" ) with your terminal and check the locale again. It should be now like this:

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


No comments:

Post a Comment