Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
949 views
in Technique[技术] by (71.8m points)

file - Unicode issue with PHP

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...