The meaning of life is to give

Reprinted from: strong little ants www.cnblogs.com/regit/p/783…

If there is infringement, please contact me to delete

Ubuntu changes the character encoding

1. Add a character encoding, for example, zh_CN. Utf-8, in either of two ways

Method 1: locale-gen zh_CN. Utf-8 #locale-gen is available only in Ubuntu

Method 2: in the/var/lib/locales/supported. D/local character set is added zh_CN. Utf-8, save the DPKG — after reconfigure locales, and then restart the computer

 

2. Change the character encoding in the /etc/default/locale file

Example 1: Solve the problem that the time format of the date command is incorrect

To add LC_TIME=” en_us. utf-8 “, run the source /etc/default/locale command. To change to Chinese, just set it to zh_cn.utF-8.

 

Example 2: If you choose Chinese to install the system, garbled characters will be displayed when you output the command on the command line interface, just change the file to the following

            LANG=”en_US.UTF-8″

LANGUAGE=”en_US:en” # Manage the output status of some commands, such as uFW status

 

3. Other character-related files

Echo $PATH = ‘/etc/environment’

2)/var/lib/locales/supported/local d this is the list of regional language has been activated

 

 

 

Centos Modifies the system-level character set

Modify /etc/sysconfig/i18n. The initial system information of the English and Chinese versions should be as follows

English Version:

LANG=”en_US.UTF-8″

SYSFONT=”latarcyrheb-sun16″

 

Chinese version system:

LANG=”zh_CN.UTF-8″

SYSFONT=”latarcyrheb-sun16″

 

If you want to use Chinese in an English system, what should you do

1. Install system support Chinese character set: yum install font-Chinese

Yum -y groupinstall Chinese-support yum -y groupinstall Chinese-support

3. Modify /etc/sysconfig/i18i as follows:

    LANG=”zh_CN.UTF-8″

#LC_ALL = zh_CN. Utf-8

    SUPPORTED=”zh_CN:zh:en_US.UTF-8:en_US:en:zh_CN.GB18030″ 

    SYSFONT=”latarcyrheb-sun16″

 

To take effect after the modification is saved and exited, run the following command

[test@pan ~]$ source /etc/sysconfig/i18n

 

 

 

Locale common commands

1. View the existing locale

2. All available locales: locale-a, which is used to check whether a character set is installed, and if not, to install it

 

 

 

The locale locale

A Locale is the Language environment in which software is run, including Language, Territory, and character set (Codeset). The writing format of a locale is: language [_ region [.character set]]. For example, zh_CN.GB2312 = Chinese _ People’s Republic of China + GB2312 character set.

 

Locale divides all aspects of the culture and tradition involved into 12 categories:

1. Language Symbols and their classification (LC_CTYPE)

2. (LC_NUMERIC)

3. Compare and sort habits (LC_COLLATE)

4. Time display format (LC_TIME)

5. LC_MONETARY

6. Messages mainly include prompt messages, error messages, status messages, titles, labels, buttons and menus (LC_MESSAGES)

7, Name writing method (LC_NAME)

8. Address writing mode (LC_ADDRESS)

9. Writing method of telephone number (LC_TELEPHONE)

10. LC_MEASUREMENT

11. Default paper size (LC_PAPER)

12. Overview of information contained in locale itself (LC_IDENTIFICATION).

 

Language symbols and their classification (LC_CTYPE), LC_CTYPE is most closely related to Chinese input, LC_CTYPE defines the effective characters in the system and the classification of these characters, such as what is uppercase letters, lowercase letters, case conversion, punctuation marks, printable characters and other character attributes

Setting locale is to set 12 categories of LOCALE attributes, that is, 12 LC_*.

 

In addition to these 12 variables that can be set, there are two more for simplicity: LC_ALL and LANG.

There is a priority relationship between them: LC_ALL>LC_*>LANG LC_ALL is the highest or mandatory setting, and LANG is the default setting.

 

Such as:

1. If you set LC_ALL = zh_CN. Utf-8, whatever LC_* and LANG are set to, they are forced to be zh_CN.

2, if you set LANG = zh_CN. Utf-8, LC_*=en_US. Utf-8, and LC_ALL is not set, the locale is LC_*=en_US.

If you set LANG = zh_CN. Utf-8 and LC_* and LC_ALL are not set, LC_* will be set to the default value of LANG zh_CN. Utf-8.

LANG = zh_CN. Utf-8 LC_CTYPE=en_US. Utf-8 LC_* and LC_ALL are not set.

The locale of the system is LC_CTYPE= en_US.utF-8, and the default values for LC_COLLATE, LC_MESSAGES, and so on are the values of LANG