Think before you speak, read before you think.

ubuntu vps使用zh_CN.utf8编码

by

in

使用

locale -a

发现只有英文编码,使用命令

bash /usr/share/locales/install-language-pack zh_CN

install-language-pack脚本内容如下:

#!/bin/sh -e

if [ -z "$1" ]; then
    echo "Usage: $0 <language code> <class> [<version>]"
    exit 0
fi

# install locales for base packages (not for gnome/kde)
# (use "--no-purge" in case PURGE=yes is used in config, which would remove
#  all other locale files)
if [ -z "$2" ]; then
    /usr/sbin/locale-gen --no-purge --lang "$1"
fi

# ensure that .desktop caches are up to date
dpkg-trigger gmenucache || true

通过如下命令,使默认编码为 zh_CN.utf8

echo LANG="zh_CN.utf8" >> /etc/environment

这样

echo $LANG显示是
zh_CN.utf8

加其他语言编码雷同

追加:
使用dpkg-reconfigure来改变语言包更简单

# dpkg-reconfigure locales

CentOS7设置 locale

localectl status # to display locale settings
localectl set-locale LANG=en_GB.utf8 # to set the Language

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *