解决locale 错误导致的中文显示问题

debian 装完软件后配置环境时,或者用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

 

重新配置locales, sudo  dpkg-reconfigure locales 后出现:
perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = (unset),

LC_ALL = (unset),

LANG = "en_US"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

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

还有类似的其他错误。locale设置错误导致:终端输入中文没反应,程序打印不了中文,vi配置正确也中文乱码。

 
参考: 
 
解决方法:
sudo vi /etc/environment
输入:
LC_CTYPE=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 LC_MESSAGE=zh_CN.UTF-8
退出重新登录即可。

你可能感兴趣的:(locale)