2017年6月21日 星期三

ubuntu中文亂碼

install locales:
sudo apt-get update && sudo apt-get install locales

sudo locale-gen zh_TW zh_TW.UTF-8 zh_CN.UTF-8 en_US.UTF-8
export LANG="zh_TW.UTF-8"

顯示目前已安裝語系
$ locale -a
顯示語系設定
$ locale
產生語系檔案
 sudo locale-gen zh_TW zh_TW.UTF-8 zh_CN.UTF-8 en_US.UTF-8

選擇安裝語系
sudo dpkg-reconfigure locales

sudo update-locale LANG="zh_TW.UTF-8" LANGUAGE="zh_TW"

個人
vim ~/.bashrc
export LC_CTYPE=zh_TW.UTF-8 # 可以輸入UTF-8中文
export LC_MESSAGES=zh_TW.UTF-8 # 可以顯示UTF-8中文

系統全域設定
sudo vim /etc/default/locale
LC_CTYPE=zh_TW.UTF-8
LC_MESSAGES=zh_TW.UTF-8
or
sudo vim /etc/environment
LC_CTYPE=zh_TW.UTF-8
LC_MESSAGES=zh_TW.UTF-8



reference:
https://unix.stackexchange.com/questions/223533/cant-install-locales
http://www.davidpai.tw/ubuntu/2011/ubuntu-set-locale/

沒有留言:

張貼留言