Simply Top Ad

Wednesday, June 16, 2010

Setting up a default locale under Ubuntu 10.04 Lucid

Do you do Perl? If so, you might like to try perldoc.co.uk. It's like perldoc.perl.org, only it's not perldoc.perl.org, so when perldoc.perl.org goes down, perldoc.co.uk stays up. Plus it's UK based, so for people in the UK and the rest of Europe, it should be quicker.

Had a problem where I had a VM running Ubuntu 10.04 Lucid but we did not have a suitable locale set to make it "work in UTF-8".

What is normally required is for the environment variable LANG to be set to something sane like en_GB.UTF-8.

On the system in question, which was derived from a bare-bones VM Ubuntu, LANG was empty. Pasting a smiley face ☺ into a PuTTY window just made it go bing. Typing a pound sign £ didn't work.

Now back in the good old days we would do something like

sudo aptitude install locales
sudo dpkg-reconfigure locales

But on my Ubuntu 10.04 Lucid system that did nothing.

Some googling around showed up remarkably little. It seems everyone just uses the GUI installer and it does everything for you. There is not much help for the command-line user.

Anyway, eventually the answer did start to become clear. The locale data is kept in separate language packs. These are represented by various packages in the standard repository, with meta-packages to link things together.

The upshot is that you need to install the relevant language pack

sudo aptitude install language-support-en

Then set the default locale as desired

update-locale LANG=en_GB.UTF-8

Log out and log in again to pick up the default locale. Then check it with

echo $LANG

This should show the default locale set earlier.

I can now paste a smiley face ☺ into PuTTY and type a pound sign £ and that all works.

If you found this article useful, please consider donating 0.50 U.S. dollars or 0.50 Euro.

No comments:

Post a Comment