Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of modifying system Code under Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Linux system installation, found that Chinese display garbled. Because the system code is en_US. UTF-8, it should be changed to support the code of Chinese (i.e. zh_CN. UTF-8)

The operation record is as follows:

0) Chinese language pack must be installed in the system

[root@xqsj-beta ~]# yum -y groupinstall chinese-support

1) Check the Linux system code

Check linux system code to see if the system supports Chinese. Enter the command: locale in the linux system terminal and you will see the printed system code information.

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

Modify system code to support Chinese

Method 1:

(2) Edit system code file

[root@xqsj-beta ~]# vim /etc/sysconfig/i18n

LANG="zh_CN.UTF-8"

[root@xqsj-beta ~]# source /etc/sysconfig/i18n

Check the system code again and find that it has been changed to support Chinese code

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

methodology II

(3) The declaration of path variables is added to the system environment variable file, which works on the whole system.

[root@xqsj-beta ~]# vim /etc/profile //Add the following at the bottom of the file

........

LC_ALL="zh_CN.UTF-8"

export LANG="zh_CN.UTF-8"

[root@xqsj-beta ~]# source /etc/profile

[root@xqsj-beta ~]# locale

---------------------------------------------------------------------------------------------

Found a problem with Chinese edited under Windows and displayed as garbled characters under Linux.

This is because Windows default encoding is GBK, while Linux default encoding is UTF-8.

To fix this, you need to change the default encoding for Linux to GBK.

[root@xqsj-beta ~]# vim /etc/sysconfig/i18n

LANG="zh_CN.GBK"

SUPPORTED="zh_CN.UTF-8:zh_CN:zh"

SYSFONT="latarcyrheb-sun16"

[root@xqsj-beta ~]# source /etc/sysconfig/i18n

[root@xqsj-beta ~]# locale

or modify system environment variables directly.

[root@xqsj-beta ~]# vim /etc/profile

......

export LC_ALL="zh_CN.GBK"

export LANG="zh_CN.GBK"

[root@xqsj-beta ~]# source /etc/profile

[root@xqsj-beta ~]# locale

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report