为什么大部分的 from localeconv 基本上都是空的?
我在 Windows 7 上运行 PHP 5.3.0、Apache 2.2.11,我尝试运行这个:
setlocale(LC_ALL, 'sv_SE.UTF-8');
print_r(localeconv());
得到这个:
Array
(
[decimal_point] => .
[thousands_sep] =>
[int_curr_symbol] =>
[currency_symbol] =>
[mon_decimal_point] =>
[mon_thousands_sep] =>
[positive_sign] =>
[negative_sign] =>
[int_frac_digits] => 127
[frac_digits] => 127
[p_cs_precedes] => 127
[p_sep_by_space] => 127
[n_cs_precedes] => 127
[n_sep_by_space] => 127
[p_sign_posn] => 127
[n_sign_posn] => 127
[grouping] => Array
(
)
[mon_grouping] => Array
(
)
)
这是怎么回事?为什么基本上所有的值都是空的或奇怪的?
I'm running PHP 5.3.0, Apache 2.2.11 on Windows 7 and I tried to run this:
setlocale(LC_ALL, 'sv_SE.UTF-8');
print_r(localeconv());
And got this:
Array
(
[decimal_point] => .
[thousands_sep] =>
[int_curr_symbol] =>
[currency_symbol] =>
[mon_decimal_point] =>
[mon_thousands_sep] =>
[positive_sign] =>
[negative_sign] =>
[int_frac_digits] => 127
[frac_digits] => 127
[p_cs_precedes] => 127
[p_sep_by_space] => 127
[n_cs_precedes] => 127
[n_sep_by_space] => 127
[p_sign_posn] => 127
[n_sign_posn] => 127
[grouping] => Array
(
)
[mon_grouping] => Array
(
)
)
What is going on here? Why are basically all the values empty or strange?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,Windows 上的语言环境命名不同...叹息...这修复了它:
Apparently locales are named differently on Windows... sigh... This fixed it:
@Svish
嗯,原因是语言环境依赖于平台。
据我所知,Linux 机器使用下划线作为分隔符。
然而,Windows 机器使用破折号作为分隔符。
例如;-
平台 | 按平台选择的首选区域设置
Linux | sv_SE
Windows | sv-SE
好的一点是
setlocale()
支持添加后备区域设置。例如;
平台将自动选择它喜欢/支持的区域设置。
您可以轻松查看平台首选的区域设置。即欲
了解更多详细信息,请查看:
https://www.php.net/manual/en/function.setlocale。 php
@Svish
Well, the reason is that locales are platform dependent.
From what I've come to notice, Linux machines use an underscore as their separator.
Yet, Windows machines use a dash as their separator.
For example;-
Platform | Preferred locale chosen by platform
Linux | sv_SE
Windows | sv-SE
The good thing is that
setlocale()
supports adding fallback locales.For example;
The platform will automatically choose the locale it prefers/supports.
You can easily view what locale has been preferred by the platform. i.e
For more details, check out:
https://www.php.net/manual/en/function.setlocale.php