Linux 中文字符集安装

查看当前字符集

$ echo $LANG
en_US.UTF-8

安装字符集

查看系统是否安装中文字符集支持

# locale -a | grep CN
bo_CN
bo_CN.utf8
ug_CN
ug_CN.utf8
zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8

若没有执行以下命令进行安装

#CentOS6.x:
yum groupinstall chinese-support
 
#CentOS7.x
yum install -y kde-l10n-Chinese
yum reinstall -y glibc-common
 
#定义字符集
localedef -i zh_CN -f UTF-8 zh_CN.UTF-8
 
#确认载入成功
locale -a

修改系统字符集

echo -e 'export LANG="zh_CN.UTF-8"\nexport LC_ALL="zh_CN.UTF-8"' > /etc/locale.conf
source /etc/locale.conf

修改属主字符集

echo 'set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936' >> /root/.vimrc;echo 'set termencoding=utf-8' >> /root/.vimrc;echo 'set encoding=utf-8' >> /root/.vimrc

 

posted on 2020-10-11 07:52  寒魔影  阅读(6375)  评论(0编辑  收藏  举报

导航