中文乱码引出的问题:en_US与en_US.utf8的区别

同事反馈, 有台服务器python无法print中文. 最后查到是因为 LANG设置问题.

系统设置为: LANG="en_US", 修改成: LANG="en_US.utf8" . 问题解决.

操作系统: CentOS 7.x
配置文件 /etc/locale.conf

en_USen_US.utf8 的区别是什么?

搜到了这篇: https://serverfault.com/questions/605776/linux-locale-en-us-utf-8-vs-en-us

$ locale -v -a
locale: en_US           archive: /usr/lib/locale/locale-archive
-------------------------------------------------------------------------------
    title | English locale for the USA
   source | Free Software Foundation, Inc.
  address | http://www.gnu.org/software/libc/
    email | [email protected]
 language | American English
territory | United States
 revision | 1.0
     date | 2000-06-24
  codeset | ISO-8859-1

locale: en_US.utf8      archive: /usr/lib/locale/locale-archive
-------------------------------------------------------------------------------
    title | English locale for the USA
   source | Free Software Foundation, Inc.
  address | http://www.gnu.org/software/libc/
    email | [email protected]
 language | American English
territory | United States
 revision | 1.0
     date | 2000-06-24
  codeset | UTF-8

即, en_US 会使用默认的字符集(codeset) ISO-8859-1, en_US.utf8使用的字符集为UTF-8.

你可能感兴趣的:(中文乱码引出的问题:en_US与en_US.utf8的区别)