author :headsen chen
date: 2018-05-14 16:20:30
一·查看字符集
字符集在系统中体现形式是一个环境变量,看当前终端使用字符集的有以下几种方式:
1:
1
2
|
[root@Testa - www tmp] # echo $LANG
zh_CN.UTF - 8
|
2:
1
2
|
[root@Testa - www ~] # env |grep LANG
LANG = zh_CN.UTF - 8
|
3:
1
2
|
[root@Testa - www ~] # export |grep LANG
declare - x LANG = "zh_CN.UTF-8"
|
4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@Testa - www ~] # locale
LANG = zh_CN.UTF - 8
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 =
|
二、修改字符集的方式
注意:
如果默认语言是en_US.UTF-8,在Linux的字符和图形界面下都是无法显示和输入中文的。
如果默认语言是中文,比如zh_CN.GB18030 或者zh_CN.gb2312,字符界面无法显示和输入,图形界面可以。
修改的方式有如下两种:
1、临时设置变量的方式修改
1
|
export LANG = zh_CN.UTF - 8
|
2、修改文件方式,通过修改/etc/sysconfig/i18n文件控制
1
2
3
|
[root@Testa - www ~] # vim /etc/sysconfig/i18n
LANG = "zh_CN.UTF-8" [root@Testa - www ~] # source /etc/sysconfig/i18n
|
补:在xshell上能看到中文:系统安装时选择中文,xshell连接后自动就能显示中文,并且字符集为: LANG
=
"zh_CN.UTF-8"