setlocale(LC_ALL, 'en_GB.UTF8') not working on windows

纵饮孤独 提交于 2019-11-28 01:49:16

问题


Why does setlocale(LC_ALL, 'en_GB.UTF8'); return false on Windows Server 2003 R2 - Zend CE PHP 5.3.5 ?

Function in question: setlocale.


回答1:


From the PHP Manual:

The return value of setlocale() depends on the system that PHP is running. It returns exactly what the system setlocale function returns.

So in your case it returns false because the system returns false. It is likely that the locale you're using is not available on your system.

A list of setlocale strings supported by Windows is available here. For British English you want eng, english-uk, or uk. Windows doesn't support multi-byte character sets like UTF-8 though; you will probably end up with Windows-1252.




回答2:


I would like to add that the problem of Windows not supporting utf-8 can be improved with something like this:

$str=strftime('%a'); //for example
if(!mb_check_encoding($str,'utf-8')) $str=utf8_encode($str);


来源:https://stackoverflow.com/questions/9489339/setlocalelc-all-en-gb-utf8-not-working-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!