In Centos, locale is used to set different language environments for running programs. locale is supported by ANSIC. The naming rule for locale is & lt; Language & gt ;_& lt; Region & gt ;. & lt; character set encoding & gt;, such as zh_CN.UTF-8, zh stands for Chinese, CN stands for mainland China, UTF-8 stands for character set. In the locale environment, there is a set of variables that represent different settings in the international environment. 1. & nbsp
In Centos, locale is used to set different language environments for running programs. locale is supported by ansi c. The naming rule for locale is <语言> _ <地区> . <字符集编码> , Such as zh_CN.UTF-8, zh represents Chinese, CN represents mainland China, UTF-8 represents character set. In the locale environment, there is a set of variables that represent different settings in the international environment.
Define sorting and comparison rules for the environment
It is used for character classification and string processing to control the processing methods of all characters, including character encoding, whether the characters are single-byte or multi-byte, and how to print them. Is the most important environment variable.
Non-currency numeric display format
Time and Date format
The language of the prompt message. There is also a LANGUAGE parameter, which is similar to LC_MESSAGES, but once this parameter is set, the LC_MESSAGES parameter will become invalid. The LANGUAGE parameter can be set to multiple languages at the same time, such
Login ane = "zh_CN.GB18030: zh_CN.GB2312: zh_CN ".
The default value of LC _ * is the lowest level. If LC _ * is not set, this value is used. Similar to LC_ALL.
It is a macro. if this value is set, this value will overwrite all the set values of LC. Note that the LANG value is not affected by this macro.
Before setting, use the default locale:
Reference debian :~ # Locale
LANG = "POSIX"
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"
After setting, use zh_CN.GDK Chinese locale:
Reference debian :~ # Export LC_ALL = zh_CN.GBK
Debian :~ # Locale
LANG = zh_CN.UTF-8
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 = zh_CN.GBK
"C" is the default locale of the system, and "POSIX" is the alias of "C. So when we install a new system, the default locale is C or POSIX.
To install locales in Debian, follow these steps:
· Use the apt-get install locales command to install the locales package
· After the locales package is installed, the system automatically configures locale. you only need to select the desired locale. Specify the default locale. In this way, the system will automatically generate the corresponding locale and configure the system locale.
· Adding a new locale is also easy. use dpkp-reconfigure locales to reconfigure locale.
· You can also manually add locale to add the new locale to the/etc/locale. gen file, and then run the locale-gen command to generate a new locale. You can set the locale of the system by setting the LC _ * Variable described above. The following is an example of a locale. gen file.
Reference # This file lists locales that you wish to have built. You can find a list
· # Of valid supported locales at/usr/share/i18n/SUPPORTED. Other
· # Combinations are possible, but may not be well tested. If you change
· # This file, you need to rerun locale-gen.
· Zh _ CN. GBK
· Zh _ CN.UTF-8 UTF-8
In Shell, the system prompts Chinese characters and supports Chinese characters. The encoding configurations of LANG and shell must be consistent, and locale is installed in Chinese. For example, both LANG and shell are encoded as zh_CN.utf8, and the locale zh_CN.utf8 is installed. If the shell and LANG configurations are different, garbled characters are displayed in Chinese. if the locale set in LANG is not installed, the Chinese prompt information of the system cannot be displayed, but only the English prompt information is displayed.