|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-04-23 15:48 UTC] sharkpp at gmail dot com
Description: ------------ Environment I'm testing this problem on Windows 7 Ultimate x86 english. Configuration changes little is required to reproduce. 1. Please open "Control Panel". 2. Please click "Change display language" link. 3. Please select "Administrative" tab and click "Change system locale..." button. 4. Please change current system locale "Japanese(Japan)". The above procedure is not needed if you want to try in the Japanese versions of Windows. php in immediately after installation, the default state is also php.ini (does not exist). Problem is_dir() will lie If you create a folder that contains the "\x5C" in the string. It may YYYY is included in the second byte of Shift_JIS. For example ソ(\x83\x5C). More example: https://ja.wikipedia.org/wiki/Shift_JIS (japanese) Test script: --------------- @mkdir("a"); @mkdir("\x83\x5D"); @mkdir("\x83\x5C"); $dir = './'; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $path = $dir . $file; $type = filetype($path); $type2= is_dir($path) ? 'dir' : 'file'; $comp = $type == $type2 ? 'OK' : 'NG'; echo "filetype()[".str_pad($type, 4)."] == is_dir()[".str_pad($type2, 4)."] -> $comp: {$file}\n"; } closedir($dh); } Expected result: ---------------- filetype()[dir ] == is_dir()[dir ] -> OK: . filetype()[dir ] == is_dir()[dir ] -> OK: .. filetype()[dir ] == is_dir()[dir ] -> OK: a filetype()[file] == is_dir()[file] -> OK: test.php filetype()[dir ] == is_dir()[file] -> NG: ソ filetype()[dir ] == is_dir()[dir ] -> OK: ゾ Actual result: -------------- filetype()[dir ] == is_dir()[dir ] -> OK: . filetype()[dir ] == is_dir()[dir ] -> OK: .. filetype()[dir ] == is_dir()[dir ] -> OK: a filetype()[file] == is_dir()[file] -> OK: test.php filetype()[dir ] == is_dir()[dir ] -> OK: ソ filetype()[dir ] == is_dir()[dir ] -> OK: ゾ PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 04:00:02 2025 UTC |
Ah, sorry... --- Insert the prefix: wfio:// is_dir("wfio://C:/") is_dir("wfio://C:\\") --- It will list entries in Shift-JIS charset, with Japanese Windows. php.exe -r "print_r(scandir('C:/'));" --- It will list entries in UTF8. php.exe -r "print_r(scandir('wfio://C:/'));" --- "wfio://" may support: fopen, fwrite, fread, stat, fclose, opendir, readdir, closedir, rename, copy, unlink, mkdir, rmdir. Here is first post about php-wfio. http://news.php.net/php.windows/30987 Thanks