Make the Linux server default to use the Chinese character set ZH_CN. UTF-8

Source: Internet
Author: User
Tags locale posix

I. Problem description and related concepts

The character set settings of a Linux server may affect the appearance of the Web page "??? "Such as the question mark garbled, but also may result in the file part of the characters garbled."

locales settings: Language Settings Options
Linux is really a very powerful system, windows if you want to change the language system, you have to reinstall the software, which is the reason that Windows has a multi-lingual version. And Linux is very convenient, we can change Linux from the English version to the Chinese version through the locales setting, let's see how to change the language settings.

Two. Causes

Simply because the server does not have ZH_CN installed. UTF-8 character set, resulting in no support for Chinese!

Locale//execute this command to view environment variables related to language encoding

Shown below:

lang=

Language=en_us:en

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=


You can see that most of the defaults are POSIX type, and you can change the server's default character set to ZH_CN. UTF-8 (I have tested changed no problem oh, can solve the problem of Chinese characters garbled. If it can be solved by setting up a terminal such as SECURECRT, there is no need to change it.

Three. Workaround

Environment: Ubuntu 12.04.5 LTS \ \l

1. Install the basic package (2nd step to install ZH_CN Chinese character set)

sudo apt-get update//ubuntu system update package list

sudo apt-get install-y Language-pack-zh-hans

sudo apt-get install-y language-pack-zh-hant

2.

Cd/usr/share/locales

sudo./install-language-pack zh_cn//Start installation ZH_CN Chinese character set

3. Edit sudo vim/etc/environment//environment variable configuration file

Add the following ZH_CN. UTF-8 about the environment variables, added to become the default OH:


Lang=zh_cn. UTF-8

Language=en_us:en

Lc_ctype= "ZH_CN. UTF-8 "

Lc_numeric= "ZH_CN. UTF-8 "

Lc_time= "ZH_CN. UTF-8 "

Lc_collate= "ZH_CN. UTF-8 "

Lc_monetary= "ZH_CN. UTF-8 "

Lc_messages= "ZH_CN. UTF-8 "

Lc_paper= "ZH_CN. UTF-8 "

Lc_name= "ZH_CN. UTF-8 "

Lc_address= "ZH_CN. UTF-8 "

Lc_telephone= "ZH_CN. UTF-8 "

Lc_measurement= "ZH_CN. UTF-8 "

Lc_identification= "ZH_CN. UTF-8 "

Lc_all=zh_cn. UTF-8


4. Re-login The shell

Source/etc/environment//Make the environment variable you just added take effect. If you do not log back into the shell, you may get an error executing this command. Oh, I tried!


Four. Simply look at the results

1.locale command look at the output!

2. You can also enter/VAR/LIB/LOCALES/SUPPORTED.D

Cat Local

Show:

en_US. UTF-8 UTF-8

Zh_cn. UTF-8 UTF-8

Instead of installing Chinese, it only shows:

en_US. UTF-8 UTF-8

Note:locale-a can view the character sets supported by the operating system.




Make the Linux server default to use the Chinese character set ZH_CN. UTF-8

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.