18

Here's the output of locale:

LANG=zh_CN.GBK
LC_CTYPE="zh_CN.GBK"
LC_NUMERIC="zh_CN.GBK"
LC_TIME="zh_CN.GBK"
LC_COLLATE="zh_CN.GBK"
LC_MONETARY="zh_CN.GBK"
LC_MESSAGES="zh_CN.GBK"
LC_PAPER="zh_CN.GBK"
LC_NAME="zh_CN.GBK"
LC_ADDRESS="zh_CN.GBK"
LC_TELEPHONE="zh_CN.GBK"
LC_MEASUREMENT="zh_CN.GBK"
LC_IDENTIFICATION="zh_CN.GBK"
LC_ALL=

How can I change all of them to UTF8? How can I make the locale setting persistent in CentOS 5.5?

5 Answers 5

16

In CentOS try with system-config-language command. That's the CentOS way :) Also you can try with:

localedef -c -f UTF-8 -i en_US en_US.UTF-8
export LC_ALL=en_US.UTF-8
2
  • what's localedef -c -f UTF-8 -i en_US en_US.UTF-8 for?
    – locale
    May 31, 2011 at 5:03
  • It's used to define your locale to en_US and en_US.UTF-8 Jun 2, 2011 at 23:25
7

Do you mean in the current session or permanently?

If you just need it in the current shell you can export the LC_ALL variable. For example:

export LC_ALL=en_US.UTF-8

If you mean to do it permanently or system-wide it varies from distribution from distribution. What's yours?

2
  • mine is centos 5.5.
    – locale
    May 31, 2011 at 3:22
  • just for session, If you close the item, Next login in LA_ALL='''
    – Love
    Jan 10, 2019 at 3:03
5

Red-Hat like distros (Centos, SL) come with file

/etc/sysconfig/i18n

which contains by default (well, in my case)

LANG="en_GB"

SYSFONT="latarcyrheb-sun16"

And above file is being sourced by /etc/profile.d/lang.sh

I my case I wanted to change en_GB.UTF-8 to en_GB.iso88591 so I found that “proper” way of doing it was to append /etc/sysconfig/i18n with

CHARSET="iso8895-1"

Once that done locale for each account on the system should be saying:

me@wark:~ $ locale

LANG=en_GB.UTF-8

LC_CTYPE="en_GB.iso88591"

LC_NUMERIC="en_GB.iso88591"

LC_TIME="en_GB.iso88591"

LC_COLLATE="en_GB.iso88591"

LC_MONETARY="en_GB.iso88591"

LC_MESSAGES="en_GB.iso88591"

LC_PAPER="en_GB.iso88591"

LC_NAME="en_GB.iso88591"

LC_ADDRESS="en_GB.iso88591"

LC_TELEPHONE="en_GB.iso88591"

LC_MEASUREMENT="en_GB.iso88591"

LC_IDENTIFICATION="en_GB.iso88591"

LC_ALL=en_GB.iso88591

2

As I suppose, after your encoding, your are chinese from mainland, you need first the chinese locale :

localedef -i zh_CN -c -f UTF-8 zh_CN.UTF-8

Then you can export you locale as :

export LANG=zh_CN.UTF-8

if you want to configure this system-wide :

change /etc/locale.conf to:

LANG=zh_CN.UTF-8
LC_COLLATE=zh_CN.UTF-8

The second line is for rules about comparing string.

Or for an user, you can just add it in you ~/.bashrc or ~/.profile

1

In CentOS 7, I was able to change the default system language by editing

/etc/profile

This is where the following variables are set

export LANG="en_GB.utf8"
export LANGUAGE="en_GB.utf8"
export LC_ALL="en_GB.utf8"

You must log in to answer this question.

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