I am using Windows 2003 to write some PHP code. I use XAMPP Portable (copy to D:). The problem:
$path = 'D:\ebooks';
$all_file = scandir($path);
foreach ($all_file as $file) {
if (is_dir("$path/$file") && $file != '.' && $file != '..') {
echo $file . "<br />\n";
}
}
When I call the script (with browser), I didn’t see any directories (within D:\ebooks) containing a Unicode character (I tested with Vietnamese, Japanese, Chinese, Czech).
But if I remove is_dir("$path/$file"), the directories display with many strange characters and many ??? characters.
How can I solve the problem?
Unfortunately, there are a lot of bugs related to PHP access to a windows filesystem. While Windows does store the filenames as UTF-16, PHP’s internals use the much older ANSI api’s. So it’s best to only do stuff with filenames that are in the ascii range, or switch to a different operating system.