duan7264 2012-06-20 11:55
浏览 23
已采纳

PHP的Unicode问题

I used dirscan php function to get an array of filename, it return an array like following:

[8] => ?????? ?????.js
[9] => ???????? ?????  ??? ?????.js
[10] => ???????? ???????????? ????????.js
[11] => ?????????? ???.js
[12] => A Contra Corriente.js
[13] => ABC-CLIO Serials Web.js
[14] => ACL.js

first three are files that their name are in Cyrillic alphabet. What should I do to get correct filenames?

  • 写回答

1条回答 默认 最新

  • dongyaobo9081 2012-06-20 16:44
    关注

    I am using win7 ntfs

    Sorry, PHP running under Windows can't support filenames containing general Unicode characters. It can only cope with filenames made entirely of characters that lie within the current code page.

    That code page is probably 1252 for you (Western European, similar to ISO-8859-1), which doesn't contain Cyrillic. If you run it on a Russian-language install then your code page would be 1251, and the Cyrillic characters would work - but accented Latin would break.

    This is a problem that affects all applications that use the standard C stdio library calls from the MS C runtime, including PHP, Java and others. (Some languages, like Python, have special support for Unicode filenames using Windows-specific APIs instead of the C stdlib; there is Request 45517 to get the same into PHP but don't hold your breath.)

    On non-Windows platforms, Unicode tends to be supported by using byte strings with the UTF-8 encoding, and so all Unicode characters just work. Unfortunately Windows does not have this capability (code page 65001 is kind-of UTF-8, but badly broken).

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

报告相同问题?

悬赏问题

  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 经gamit解算的cors站数据再经globk网平差得到的坐标做形变分析
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式