Linux Character Set Problems

Source: Internet
Author: User
Tags i18n

Linux Character Set Problems

During Linux system logon or remote operations, or sometimes when we use man in a character terminal to view instructions for a command, the content may contain garbled characters similar to <A1> <AE>. In this case, you can use the following command to eliminate garbled characters:

Bkjia@www.bkjia.com ~ $ Unset LANG

What is the problem? This requires a concept-character set,

Why is the character set mentioned? reference: "locale is a very important concept in the process of internationalization and localization. I personally think that for Chinese users, it usually involves internationalization or localization, there are roughly three aspects: Reading Chinese, writing Chinese, and compatibility and communication with the Windows Chinese system. From the practical experience, locale settings have little to do with Chinese, but they are closely related to Chinese writing and the mounting mode of window partitions ."

1. View character sets
Character Set is an environment variable in the system. Taking RedHat as an example (bshell), you can view the character set used by the current terminal in the following ways:
1) [bkjia@www.bkjia.com ~] $ Env | grep LANG
LANG = zh_CN.GB18030
2) [bkjia@www.bkjia.com ~] $ Export | grep LANG
Declare-x LANG = "zh_CN.GB18030"
3) There is also a very powerful command: locale
Bkjia@www.bkjia.com ~ $ 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.

View and modify the Linux Character Set

Ii. How to modify character sets
If the default language is en_US.UTF-8, the characters and graphical interfaces in Linux 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) directly set the variable to modify. The command is as follows:
Bkjia@www.bkjia.com ~ $ LANG = xxx or export LANG = xxx;
Bkjia@www.bkjia.com ~ $ 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. Create shell. The environment variable disappears.
Therefore, when you log on to the system and execute the "LANG =" command, there is no garbled code. This means that the display of character sets is canceled.
2) modify the file mode by modifying the/etc/sysconfig/i18n File
Bkjia@www.bkjia.com ~ $ Vi/etc/sysconfig/i18n
LANG = "zh_CN.GB18030" #=> this 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:
Bkjia@www.bkjia.com ~ $ Source/etc/sysconfig/i18n
When you log on to the shell, the user will read

This article permanently updates the link address:

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.