CentOS6.6系统如何设置中文

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6.6系统如何设置中文相关的知识,希望对你有一定的参考价值。

[[email protected] ~]# cat a.txt 

??


以上是乱码,两个问号。

中文支持操作如下:

1、查看当前语言支持

[[email protected] ~]# echo $LANG
en_US.UTF-8

2、查看安装的语言包

[[email protected] ~]# 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、没有中文包则在线安装

[[email protected] ~]# yum groupinstall chinese-support

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

[[email protected] ~]# 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、查看当前字符集配置

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

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

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

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

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

[[email protected] ~]# 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、执行修改生效命令

[[email protected] ~]# source /etc/sysconfig/i18n

8、再查看安装的语言包

[[email protected] ~]# 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就可看到中文了

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


本文出自 “10628473” 博客,请务必保留此出处http://10638473.blog.51cto.com/10628473/1746095

以上是关于CentOS6.6系统如何设置中文的主要内容,如果未能解决你的问题,请参考以下文章

如何通过代码设置片段标签?

Centos6.6系统root用户密码恢复案例

centos6.6 版本操作系统优化

如何设置 vscode 的代码片段,以便在自动完成后自动触发 vscode 的智能感知?

如何从设置中获取数据并发送到此片段

Centos6.6安装后一些常见问题详解