Bug #50028 [Opn->Csd]: dirname bug

From: Date: Tue, 17 Oct 2017 12:30:43 +0000
Subject: Bug #50028 [Opn->Csd]: dirname bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211759@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50028&edit=1 ID: 50028 Updated by: cmb@php.net Reported by: zgq0301 at gmail dot com Summary: dirname bug -Status: Open +Status: Closed Type: Bug Package: Filesystem function related Operating System: win32 only PHP Version: 5.2.11 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Closing according to previous comment. Previous Comments: ------------------------------------------------------------------------ [2014-01-30 21:31:57] cmbecker69 at gmx dot de It seems to me that this is not a bug, but rather a character encoding resp. locale related issue. As the documentation of dirname()[1] states: | dirname() is locale aware, so for it to see the correct | directory name with multibyte character paths, the matching | locale must be set using the setlocale() function. FWIW: Assuming UTF-8, the test script could be written: $file = "D:\\Backup\\\xE6\x88\x91\xE7\x9A\x84\xE6\x96\x87" . "\xE6\xA1\xA3\\\xE7\xBD\x91\xE7\xAB\x99\xE6\xA0\xB9" . "\xE7\x9B\xAE\xE5\xBD\x95\cms"; echo dirname($file); [1] <http://php.net/manual/en/function.dirname.php#refsect1-function.dirname-notes> ------------------------------------------------------------------------ [2009-10-31 14:00:50] kalle@php.net sjoerd> Thats bugsweb causing that on unicode characters, first they are converted to entities sjoerd> and then the & is escaped into &amp;. So it ends up with &amp;#XXXX; =) ------------------------------------------------------------------------ [2009-10-29 19:55:50] sjoerd@php.net Thank you for your bug report. You have html entities in your filename. Html entities are not automatically decoded when used in filenames. ------------------------------------------------------------------------ [2009-10-29 00:49:31] zgq0301 at gmail dot com Description: ------------ function dirname can't return a string which the last character is chinese. Reproduce code: --------------- --- From manual page: function.dirname#Description --- code: $file="D:\Backup\&#25105;&#30340;&#25991;&#26723;\&#32593;&#31449;&#26681;&#30446;&#24405;d\cms"; echo dirname($file); then it print D:\Backup; but when I add a english character: $file="D:\Backup\&#25105;&#30340;&#25991;&#26723;\&#32593;&#31449;&#26681;&#30446;&#24405;d\cms"; echo dirname($file); it can well done. Expected result: ---------------- code: $file="D:\Backup\&#25105;&#30340;&#25991;&#26723;\&#32593;&#31449;&#26681;&#30446;&#24405;d\cms"; echo dirname($file); then it print D:\Backup; but when I add a english character: $file="D:\Backup\&#25105;&#30340;&#25991;&#26723;\&#32593;&#31449;&#26681;&#30446;&#24405;d\cms"; echo dirname($file); it can well done. Actual result: -------------- code: $file="D:\Backup\&#25105;&#30340;&#25991;&#26723;\&#32593;&#31449;&#26681;&#30446;&#24405;d\cms"; echo dirname($file); then it print D:\Backup; but when I add a english character: $file="D:\Backup\&#25105;&#30340;&#25991;&#26723;\&#32593;&#31449;&#26681;&#30446;&#24405;d\cms"; echo dirname($file); it can well done. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=50028&edit=1

« previous php.bugs (#211759) next »