Liang
V2EX  ›  PHP

原来 CentOS 和 OS X 的 locale 不一样

  •  
  •   Liang · Apr 3, 2016 · 2932 views
    This topic created in 3866 days ago, the information mentioned may be changed or developed.
    今天在做一个日期的中文输出时( OS X ),用了 setlocale(LC_TIME, 'zh_CN.UTF-8'),部署到生产环境( CentOS )后,日期居然显示空白。注释掉 setlocale 后,日期显示为英文,问题定位在 setlocale 上。
    生产环境 locale -a 看了一下,发现 zh_CN 是 utf8 的写法,迅速改成 setlocale(LC_TIME, 'zh_CN.utf8')后正常。

    请问有统一的方法吗?(不想为此增加一个配置,完美强迫症
    3 replies  •  2016-04-04 17:42:52 +08:00
    kendetrics
    kendetrics
    Apr 3, 2016
    1
    docker 就是用来解决这些问题的。。
    salmon5
    salmon5
    Apr 3, 2016
    2
    判断系统类型。这世界不完美的东西多了。
    julyclyde
    julyclyde
    Apr 4, 2016
    3
    什么是“是 utf8 的写法”?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3083 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 11:40 · PVG 19:40 · LAX 03:40 · JFK 06:40
    ♥ Do have faith in what you're doing.