Unicode issue with PHP

前端 未结 1 395
醉梦人生
醉梦人生 2020-12-18 16:28

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

[8] => ?????? ?????.js
[9] => ???????? ?????           


        
相关标签:
1条回答
  • 2020-12-18 17:21

    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).

    0 讨论(0)
提交回复
热议问题