简单解决Ubuntu修改locale的问题

前端之家收集整理的这篇文章主要介绍了简单解决Ubuntu修改locale的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

psql提示

perl: warning: Setting locale Failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_HK:en",LC_ALL = (unset),LC_PAPER = "zh_CN.UTF-8",LC_ADDRESS = "zh_CN.UTF-8",LC_MONETARY = "zh_CN.UTF-8",LC_NUMERIC = "zh_CN.UTF-8",LC_TELEPHONE = "zh_CN.UTF-8",LC_IDENTIFICATION = "zh_CN.UTF-8",LC_MEASUREMENT = "zh_CN.UTF-8",LC_TIME = "zh_CN.UTF-8",LC_NAME = "zh_CN.UTF-8",LANG = "en_HK.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_HK.UTF-8").

select * from test;

里边存储汉子的字段 竟然 是 
<E6><9D><8E>
....

查看client_encodeing的默认字符

 show client_encoding;
 client_encoding -----------------
 sql_ASCII

#设置为UTF8

\encoding UTF8

设置完没有变过来 囧囧囧

上网查找竟然是本地字符集的问题:

$locale

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=zh_CN.UTF8
LANGUAGE=en_HK:en
LC_CTYPE="zh_CN.UTF8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="zh_CN.UTF8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="zh_CN.UTF8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=

要想达到应用程序中正常显示中文字符的目的,要下面的三个变量应该如下:

LANG=zh_CN.UTF-8 
LANGUAGE=zh_CN:zh:en_US:en 
LC_ALL=LC_ALL=zh_CN.UTF-8

支持中文简体执行:
sudo apt-get -y install language-pack-zh-hans

支持中文繁体执行:
sudo apt-get -y install language-pack-zh-hant

再去psql链接数据库执行sql 直接可以显示中文了,也没有这以下
warning 了:

$psql_db
psql (9.6.4)
Type "help" for help.
原文链接:https://www.f2er.com/ubuntu/350890.html

猜你在找的Ubuntu相关文章