Steps to solve linux displaying Chinese garbled characters

In the past few days, the test environment was rebuilt and it was found that the Chinese logs under linux (centos6) all displayed garbled characters.

Then I searched and sorted out the solution steps:

 

1. View the default language used by the current system. Use the command: echo $LANG

 

2. If the setting is not LANG= zh_CN.UTF-8   , use the locale command to check whether the Chinese language pack is installed in the system

(If it is not installed, install it, it will not be described in detail here)

 

3. Set the system default language LANG= zh_CN.UTF-8 

 

4. Execute the command source  /etc/sysconfig/i18n (the configuration takes effect)

 

5. Modify the terminal character set to UTF-8

 

Note: A lot of information on the Internet is written here, but after testing, the problem has not been solved, and the following steps have been added after some exploration

 

6. Modify the environment variable vim /etc/profile  to add export LC_ALL="zh_CN.UTF-8"

 

7. Execute the command source  /etc/ profile   (the configuration takes effect)

 

Check again that Chinese characters have been displayed normally

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326864777&siteId=291194637