Unicode setlocale和strftime在Windows上失败 [英] Unicode setlocale and strftime fails at windows

查看:413
本文介绍了Unicode setlocale和strftime在Windows上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一页,其编码为UTF-8,如果我尝试在unix系统中运行该代码,一切都很好,但是当我尝试在Windows(7)中运行时,有些迷惑的人会问号( ).如何在两个系统上都运行良好的代码(不使用iconv).

I have one page and it's encoding is UTF-8 and If i try to run that code in unix system everythings looks fine but when i try to run in windows(7) some chracters looks question mark(�). How can run the code fine both of two system(without using iconv).

header('Content-Type: text/html; charset=UTF-8');
setlocale(LC_ALL, 'turkish');
echo strftime("%d %B %Y, %H:%M");

推荐答案

对于那些在linux上有类似问题的人(这可能也适用于Windows,但不确定).

For those who is having similar problems on linux (this may work also for windows but not sure).

是的,有土耳其语",但也有"tr_TR.utf8".如果您使用"tr_TR.utf8",则您的问题很可能会被淘汰.同样的东西也适用于希腊语".而是使用"el_GR.utf8"

Yes there is 'turkish' but there is also 'tr_TR.utf8' . If you use 'tr_TR.utf8' most probably your problems will be washed away. Same thing applies also to 'greek'. Instead use 'el_GR.utf8'

在linux上,您可以检查语言环境列表以找到适合您站点的正确设置.

On linux you can check the locale list to find the proper settings for your site.

locale -a

列表太长,您看不到所有语言,因此可以将其转储到文件中,然后打开文件进行检查.

List is too long and you can't see all languages, so either you can just dump it into a file and then open the file to check.

locale -a > locale.txt
vi locale.txt

或执行 locale -a | grep语言代码 (用于特定语言)

or do locale -a | grep languagecode for a specific language

locale -a | grep tr

这篇关于Unicode setlocale和strftime在Windows上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆