I have a directory which contains several files, many of which has non-english name. I am using PHP in Windows 7.
I want to list the filename and their content using PHP.
Currently I am using DirectoryIterator
and file_get_contents
. This works for English files names but not for non-English (chinese) file names.
For example, I have filenames like "?? ?? ?????????.eml", "hello ??????.eml".
DirectoryIterator
is not able to get the filename using->getFilename()
file_get_contents
is also not able to open even if I hard code the filename in its parameter.
How can I do it?
This is not possible. It's a limitation of PHP. PHP uses the multibyte versions of Windows APIs; you're limited to the characters your codepage can represent.
See this answer.
Directory contents:
Test file contents:
Test file results:
Debugger output:
Call stack (PHP 5.3.0):
Is it really a question mark?
Yes! It's character #63.