Bug #74927 [NEW]: UTF8 characters wrong processed in file system

From: Date: Fri, 14 Jul 2017 19:52:40 +0000
Subject: Bug #74927 [NEW]: UTF8 characters wrong processed in file system
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210061@lists.php.net to get a copy of this message
From: furun at arcor dot de Operating system: Win7 and Linux PHP version: 7.1.7 Package: *Directory/Filesystem functions Bug Type: Bug Bug description:UTF8 characters wrong processed in file system Description: ------------ UTF8 characters wrong processed in file system PHP 7.1.7, Win7, Xampp PHP 7.1.5, Linux PHP has problems to process UTF8 characters in files correctly. there are maybe multiple buggy file-functions, but i tested: file_put_contents, file_get_contents, glob. file_put_contents, file_get_contents writes and reads files correctly, but glob don't list them correctly. (is there a .htaccess or PHP or system option to fix this, or it is a PHP-Code problem? i think it is a PHP bug.) (PHP7 has still a very weak support of UFT8 encoding? maybe all file functions should be tested?) Results: in both OS systems (Windows 7 and Linux), the files are created correctly. but they are not read back correctly with glob(), file_put_contents, file_get_contents (OK): !äÄ ä!Ä äÄ! ä!Ä.txt äÄ.txt ÿ.txt Āﻼ.txt أ¤أ„.tx2 glob() (BUG): PHP_OS: WINNT ÿ.txt 8 ä!Ä.txt 9 äÄ.txt 8 Āﻼ.txt 9 أ¤أ„.tx2 13 PHP_OS: Linux .txt 4 !Ä.txt 7 .txt 4 .txt 4 .tx2 4 Test script: --------------- define('DIR_BASE', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR); define('DIR_TEMP', DIR_BASE . 'temp' . DIRECTORY_SEPARATOR); print(DIR_BASE . '<br>'); print(DIR_TEMP . '<br>'); print('<br>'); print('PHP_OS: ' . PHP_OS . '<br><br>'); try { if (! file_exists(DIR_TEMP) && ! is_dir(DIR_TEMP)) { $check = mkdir(DIR_TEMP, 0755); if ($check) $check = chmod(DIR_TEMP, 0755); } } catch (Exception $exception) { } print('file_put_contents, file_get_contents:<br>'); $fileName = "!äÄ"; file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $fileName = "ä!Ä"; file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $fileName = "äÄ!"; file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $fileName = "ä!Ä.txt"; file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $fileName = "äÄ.txt"; file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $fileName = " ÿ.txt"; file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $fileName = "Āﻼ.txt"; file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $fileName = "äÄ.tx2"; $fileName = iconv('windows-1256', 'utf-8', $fileName); file_put_contents(DIR_TEMP . $fileName, $fileName); $data = file_get_contents(DIR_TEMP . $fileName); print($data . '<br>'); $data = ''; $data .= '<table class="text documentlist sortable">' . "\n"; $data .= '<tbody>' . "\n"; print('<br><br>glob:<br>'); $fileList = glob(DIR_TEMP . '*.*', 0); foreach ($fileList as $filePath) { $fileName = basename($filePath); $data .= '<tr">' . '<td>' . '<a href="temp/' . htmlentities(urlencode($fileName)) . '">' . $fileName . '</a></td>'. '<td>' . strlen($fileName) . '</td>'. '</tr>' . "\n"; //FIXME Einlesen } $data .= '</tbody>' . "\n"; $data .= '</table>' . "\n"; print($data); Expected result: ---------------- all files listed in correct names -- Edit bug report at https://bugs.php.net/bug.php?id=74927&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74927&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74927&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74927&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74927&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74927&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74927&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74927&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74927&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74927&r=support Expected behavior: https://bugs.php.net/fix.php?id=74927&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74927&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74927&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74927&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74927&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74927&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74927&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74927&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74927&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74927&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74927&r=mysqlcfg

« previous php.bugs (#210061) next »