There seems to be a bug in Ubuntu 12.04 with setting locales for users, the root locales are set but this doesn’t seem to filter down to individual user accounts.
This might not be a problem for you until you ssh into your server. And by the way this seems to be affecting Debian variants, I haven’t checked Debian but my Raspberry Pi which are running Raspbian, a variant of Debian, is affected too. This bug does not affect the desktop version of this OS, only if installed on server (minimal install).
Now I use three different OS to ssh with windows Putty, OSX terminal and a Linux terminal and I want the same locale encoding on all three.
As a programmer I like to use UTF-8 encoding for my HTML, PHP, JS and CSS files so this is the encoding default for all my systems.
I only really noticed this when I was using ssh on my iPad and Midnight Commander on the server and the terminal had strange letters where lines should be but when I used mc as root everything was the way it should be! So I knew I had a problem so I googled for a solution and tried several, which didn’t work, and come to the right one eventually.
So with that said here is how I fixed it:
First we need to see what locale settings the user has set so in a terminal enter
locale
If this shows what is below then you have this bug.
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
Now I use British English so in ‘~/.bashrc’, add at the bottom
export LANG="en_GB.UTF-8"
export LANGUAGE="en_GB:en"
export LC_CTYPE="en_GB.UTF-8"
export LC_NUMERIC="en_GB.UTF-8"
export LC_TIME="en_GB.UTF-8"
export LC_COLLATE="en_GB.UTF-8"
export LC_MONETARY="en_GB.UTF-8"
export LC_MESSAGES="en_GB.UTF-8"
export LC_PAPER="en_GB.UTF-8"
export LC_NAME="en_GB.UTF-8"
export LC_ADDRESS="en_GB.UTF-8"
export LC_TELEPHONE="en_GB.UTF-8"
export LC_MEASUREMENT="en_GB.UTF-8"
export LC_IDENTIFICATION="en_GB.UTF-8"
export LC_ALL=
Now this has to be done for ever user so put this code in ‘/etc/skel/.bashrc’ then every new user will have this default encoding set.
For more info on locales
If anyone has another way that works please feel free to post it.