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

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

作者: L2020 | 来源:发表于2019-12-20 22:43 被阅读0次

    同事反馈, 有台服务器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 | bug-glibc-locales@gnu.org
     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 | bug-glibc-locales@gnu.org
     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的区别

          本文链接:https://www.haomeiwen.com/subject/jqkwnctx.html