Ubuntu system Chinese display garbled code problem solved

  • 2020-05-17 07:31:44
  • OfStack

If you have Chinese characters scrambled in Ubuntu system, it may be because the system has not configured Chinese character encoding.

The solution

The character encoding of the Ubuntu system is saved in a file /var/lib/locales/supported.d/local In the.

To add Chinese character encoding to the Ubuntu system, you can directly use locale-gen:


sudo locale-gen zh_CN.UTF-8

Use the above command to complete the addition of Chinese character set /var/lib/locales/supported.d/local Add 1 line to the file as follows:


zh_CN.UTF-8 UTF-8

You can also modify it directly /var/lib/locales/supported.d/local File, you can first check the content of the file, roughly as follows:


zh_CN.UTF-8 UTF-8
en_US.UTF-8 UTF-8
zh_CN.GB18030 GB18030
zh_CN.GBK GBK

If you want to add a character set to Linux, you can directly add a line of the corresponding character encoding to the end of the file, and then execute the following command:


sudo dpkg-reconfigure locales

System to support Chinese, the system needs to have the corresponding Chinese language environment package. Install simplified Chinese language pack:


sudo apt-get install language-pack-zh-hans language-pack-zh-hans-base language-pack-gnome-zh-hans language-pack-gnome-zh-hans-base

Or:


sudo apt-get install `check-language-support -l zh-hans`

Just restart or log in again.

conclusion


Related articles: