View and modify the Linux Character Set

Source: Internet
Author: User

1. View character sets
The character set is embodied in the system as an environmental variable. Taking centos as an example, you can view the character set used by the current terminal in the following ways:

1. [root @ david ~] # Echo $ LANG
Zh_CN.GB18030
2. [root @ david ~] # Env | grep LANG
LANG = zh_CN.GB18030
LANGUAGE = zh_CN.GB18030: zh_CN.GB2312: zh_CN
3. [root @ david ~] # Export | grep LANG
Declare-x LANG = "zh_CN.GB18030"
Declare-x LANGUAGE = "zh_CN.GB18030: zh_CN.GB2312: zh_CN"
4. [root @ david ~] # Locale
LANG = zh_CN.GB18030
LC_CTYPE = "zh_CN.GB18030"
LC_NUMERIC = "zh_CN.GB18030"
LC_TIME = "zh_CN.GB18030"
LC_COLLATE = "zh_CN.GB18030"
LC_MONETARY = "zh_CN.GB18030"
LC_MESSAGES = "zh_CN.GB18030"
LC_PAPER = "zh_CN.GB18030"
LC_NAME = "zh_CN.GB18030"
LC_ADDRESS = "zh_CN.GB18030"
LC_TELEPHONE = "zh_CN.GB18030"
LC_MEASUREMENT = "zh_CN.GB18030"
LC_IDENTIFICATION = "zh_CN.GB18030"
LC_ALL =
LC_CTYPE indicates that the character set used by the system is zh_CN.GB18030, LC_NUMERIC (Display message of the digital system), and other language-related variables. If other language variables are not set, you can set the LANG variable to replace all other variables by default.


Ii. How to modify character sets
Note: If the default language is en_US.UTF-8, Linux characters and graphical interfaces are not displayed and enter Chinese. If the default language is Chinese, for example, zh_CN.GB18030 or zh_CN.gb2312, the character interface cannot be displayed or input. The graphic interface can be used.
There are two ways to modify:
1. Modify the variables directly by using the following two commands:
[Root @ david ~] # LANG = xxx or export LANG = xxx;
[Root @ david ~] # LC_ALL = "xxx" or export LC_ALL = "xxx ";
Note: xxx indicates the character set to be modified.
The locale-a command is used to view standard character sets. commonly used methods include zh_CN.GB2312,
Zh_CN.GB18030 or zh_CN.UTF-8, en_US.UTF-8, etc.
However, the preceding modification only takes effect in the current shell, and the environment variable "new shell" disappears.
Therefore, no garbled characters are displayed when you log on to the system and run the "LANG =" command. This means that the display of the character set is canceled. You can also run the [root @ david ~] command to cancel the character set. # Unset LANG.
2. Modify the file mode by modifying the/etc/sysconfig/i18n File
[Root @ david ~] # Vim/etc/sysconfig/i18n
LANG = "zh_CN.GB18030" is the system language.
SUPPORTED = "zh_CN.UTF-8: zh_CN.GB18030: zh_CN: zh: en_US.UTF-8: en_US: en"
SYSFONT = "lat0-sun16"
After saving and exiting the modified file, the modification takes effect only after the following command is executed:
[Test @ pan ~] $ Source/etc/sysconfig/i18n

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.