current position:Home>Handling of Chinese garbled code in Ubuntu

Handling of Chinese garbled code in Ubuntu

2022-01-26 22:23:13 Yan Long

adopt docker Downloaded a brand new ubuntu Mirror image , After running, it is found that Chinese is displayed as garbled .


reason :

Generally, there are two reasons for Chinese garbled code :

  1. The default language set does not support displaying Chinese
  2. The Chinese language pack is not installed in the system


  1. View the current system language
$ echo $LANG

2. Check the language pack installed on the system

$ locale -a 

$ sudo dpkg -l | grep language-pack-zh-hans
  1. If there is no Chinese language pack , Need to install
$ sudo apt-get install language-pack-zh-hans
  1. After successful installation , Confirm whether the installation is successful
$ locale -a 

$ sudo dpkg -l | grep language-pack-zh-hans
ii  language-pack-zh-hans           1:20.04+20210802                    all          translation updates for language Simplified Chinese
ii  language-pack-zh-hans-base      1:20.04+20210802                    all          translations for language Simplified Chinese
  1. Set system locale
// export  This method only works for the current terminal 
$ export LANG="zh_CN.UTF-8"

//  /etc/profile  Add... To the file export LANG="zh_CN.UTF-8"  Effective for all users 
$ vim /etc/profile

copyright notice
author[Yan Long],Please bring the original link to reprint, thank you.

Random recommended