[root@N1 ~]# cat a.txt 

??


以上是乱码,两个问号。

中文支持操作如下:

1、查看当前语言支持

[root@N1 ~]# echo $LANG
en_US.UTF-8

2、查看安装的语言包

[root@N1 ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

3、没有中文包则在线安装

[root@N1 ~]# yum groupinstall chinese-support

4、安装完成之后查看支持的字符集

[root@N1 ~]# locale -a

有很多,滚动条向下拉可以看到中文支持的字符集

zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8
zh_HK
zh_HK.big5hkscs
zh_HK.utf8
zh_SG
zh_SG.gb2312
zh_SG.gbk
zh_SG.utf8
zh_TW
zh_TW.big5
zh_TW.euctw
zh_TW.utf8
zu_ZA
zu_ZA.iso88591
zu_ZA.utf8

5、查看当前字符集配置

[root@N1 ~]# cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

6、修改配置为中文字符集

[root@N1 ~]# vi /etc/sysconfig/i18n 
LANG="zh_CN.GB2312"
SUPPORTED="zh_CN.GB2312:zh_CN:zh"
SYSFONT="latarcyrheb-sun16"

温馨提示:由于我用的远程终端SecureCRT只支持GB2312,所以才修改为GB2312,让我的SecureCRT显示中文,如果直接在虚拟机上还是中文乱码的。

如果想直接在CentOS6.6终端上支持中文,可先查看支持的字符集

[root@N1 ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

这样就可看出系统支持UTF-8字符集,接下来按照接下来的步骤修改为UTF-8字符集即可。

7、执行修改生效命令

[root@N1 ~]# source /etc/sysconfig/i18n

8、再查看安装的语言包

[root@N1 ~]# locale
LANG=zh_CN.GB2312
LC_CTYPE="zh_CN.GB2312"
LC_NUMERIC="zh_CN.GB2312"
LC_TIME="zh_CN.GB2312"
LC_COLLATE="zh_CN.GB2312"
LC_MONETARY="zh_CN.GB2312"
LC_MESSAGES="zh_CN.GB2312"
LC_PAPER="zh_CN.GB2312"
LC_NAME="zh_CN.GB2312"
LC_ADDRESS="zh_CN.GB2312"
LC_TELEPHONE="zh_CN.GB2312"
LC_MEASUREMENT="zh_CN.GB2312"
LC_IDENTIFICATION="zh_CN.GB2312"
LC_ALL=

9、重新编辑a.txt就可看到中文了

[root@N1 ~]# vi a.txt 
你好啊  亲
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
~                                                                   
"a.txt" 1L, 11C written
[root@N1 ~]# cat a.txt
你好啊  亲