|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-09-05 22:05 UTC] pajoye@php.net
[2009-09-05 22:41 UTC] elmue at gmx dot de
[2009-09-05 23:38 UTC] pajoye@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
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"