From: elmue at gmx dot de Operating system: Windows PHP version: 6SVN-2009-09-05 (snap) PHP Bug Type: *Unicode Issues Bug description: readdir fails for Unicode filenames
Description: ------------ Hello I have PHP6 - VC6 compiled on 3. Sept 2009. How to reproduce the bug: Create a file: C:\Temp\Tést.txt (note the accent on the e) Execute the code below. What happens is the warning: "Could not convert binary string to Unicode string (converter UTF-8 failed on bytes (0xE9) at offset 1)" (E9 is the Ascii code of the 'é' character) and an empty string is returned in $File. If the filename contains russian or greek characters it is even worse: In this case no warning is displayed and the filename is returned as "??????.txt" This warning message is nonsense. All Windows Operating Systems store Filenames in Unicode except Windows 95,98,ME which are out of date. So there is no reason to put the filename into an UTF-8 converter as the warning says. There is no conversion required on Windows if the correct API is used. Windows offers the old FindFirstFileA(...) API and the Unicode FindFirstFileW(..) API. I hope that the PHP programmers did not make the error to use the Ansii versions which are Codepage dependent and produce a !lot! of problems. The Wide API like FindFirstFileW(...) returns ALL filenames directly in Unicode. There is NO CONVERSION required on Windows and there is NO UTF-8 converter required. I also played around with different settings for ini_set("unicode.filesystem_encoding", "...") but the error stays the same. There is design error deep in the code. Elmü Reproduce code: --------------- <?php $hDir = opendir("C:\\Temp"); while ($hDir) { $File = readdir($hDir); // <--- produces warning if ($File === false) break; echo "File=$File<br>"; } ?> Expected result: ---------------- correct filename no warning Actual result: -------------- the file is returned as empty string or as "?????.txt" -- Edit bug report at http://bugs.php.net/?id=49475&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49475&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49475&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49475&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49475&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49475&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49475&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49475&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49475&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49475&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49475&r=support Expected behavior: http://bugs.php.net/fix.php?id=49475&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49475&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49475&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49475&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49475&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49475&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49475&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49475&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49475&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49475&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49475&r=mysqlcfg