5

How can I change the default codepage/charset on a linux system from latin1 to utf8? I need to do this on two systems, one is running Ubuntu and the other Debian.

tangens
  • 1,780
  • 2
  • 20
  • 20

2 Answers2

8

Edit /var/lib/locales/supported.d/local and add your locale to the list of supported locales if it isn't there already, eg:

en_US UTF-8

Regenerate the supported locales on your machine:

sudo dpkg-reconfigure locales

Open /etc/default/locale and check if LANG and LANGUAGE are changed:

LANG="en_US"
LANGUAGE="en_US:UTF-8"

if they are not, you can manually update them now.

reboot.

John T
  • 163,373
  • 27
  • 341
  • 348
  • good answer, john, thx. do you know what package adds the /var/lib/locales stuff? my recent Debian 5.0.3 install doesn't provide that, although an old Ubuntu 7.04 install did. – quack quixote Oct 14 '09 at 12:59
  • Debian's locale settings are in `/etc/locale.gen` I believe. – John T Oct 14 '09 at 14:00
  • hmmm. that looks like the stuff i selected during the `dpkg-reconfigure locales`, it's probably generated there. maybe the old Ubuntu install generated the /var/lib/locales stuff too, `dpkg -S` doesn't find an associated package. the Debian install does use the `/etc/default/locale` file for selecting system default. – quack quixote Oct 14 '09 at 14:59
0

If you also need to switch latin1 encoded filenames to utf-8, use convmv (apt-get install convmv):

convmv -f latin1 -t utf8 -r /path/to/files

This will only show what it would do. Add the --no-test option to actually do it.

mivk
  • 3,441
  • 36
  • 33