系统字符编码

CentOS-6

1.查看编码信息

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

[root@localhost ~]# 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=

查看当前系统支持的字符集:

[root@localhost ~]# locale -a

2.临时修改

[root@localhost ~]# LANG=en_US.UTF-8	# 基本用不到

3.永久修改

方法一:

[root@localhost ~]# vim /etc/profile
文件最后添加:export LANG='en_US.UTC'
[root@localhost ~]# source /etc/profile
[root@localhost ~]# echo $LANG
en_US.UTC

方法二:

[root@localhost ~]# vim /etc/sysconfig/i18n
[root@localhost ~]# cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
[root@localhost ~]# source /etc/sysconfig/i18n
[root@localhost ~]# echo $LANG
en_US.UTF-8

CentOS-7

1.查看编码信息

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

[root@localhost ~]# 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=

查看当前系统支持的字符集:

[root@localhost ~]# locale -a

2.临时修改

[root@localhost ~]# LANG=en_US.UTF-8	# 基本用不到

3.永久修改

方法一:

[root@localhost ~]# vim /etc/profile
文件最后添加:export LANG='en_US.UTC'
[root@localhost ~]# source /etc/profile
[root@localhost ~]# echo $LANG
en_US.UTC

方法二:

[root@localhost ~]# vim /etc/locale.conf
[root@localhost ~]# cat /etc/locale.conf
LANG="zh_CN.UTF-8"
[root@localhost ~]# source /etc/locale.conf
[root@localhost ~]# echo $LANG
zh_CN.UTF-8

方法三:

[root@localhost ~]# localectl set-locale LANG=zh_CN.UTF-8
posted @ 2020-10-29 14:23  忘川的彼岸  阅读(136)  评论(0编辑  收藏  举报