Real Dreams
Real Dreams

Reputation: 18010

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?

Upvotes: 1

Views: 691

Answers (1)

bobince
bobince

Reputation: 536339

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

Upvotes: 4

Related Questions