dongmou3615 2014-03-24 08:30
浏览 29
已采纳

PHP 5.5 setlocale()在Windows上无法在CLI中运行?

I'm diagnosing some user problems with German locales. Running

php -r "setlocale(LC_ALL, array('de_DE','deu_deu)); echo 10.01;"

gives

10.01

Running

<?php
echo(setlocale(LC_ALL,array('de_DE','deu_deu')));
echo 10.01;

via WAMP stack gives

German_Germany.1252 10,01

This shows that locale is active and the decimal_point has changed.

Is it a known restricting that setlocale doesn't work in CLI?

  • 写回答

1条回答 默认 最新

  • doujie9252 2014-03-27 10:16
    关注

    After opening an issue with PHP it turns indeed out to be a bug: https://bugs.php.net/bug.php?id=65230

    Funny (or rather not) is that obviously broken behavior won't get fixed or even documented:

    And after all, locale has such issues on any platform. The solution is to use intl or custom localization functionality.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?