Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer
    
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

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .