php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50028 dirname bug
Submitted: 2009-10-29 00:49 UTC Modified: 2017-10-17 12:30 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: zgq0301 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.2.11 OS: win32 only
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zgq0301 at gmail dot com
New email:
PHP Version: OS:

 

 [2009-10-29 00:49 UTC] 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\我的文档\网站根目录d\cms";
echo dirname($file);

then it print D:\Backup;
but when I add a english character:

$file="D:\Backup\我的文档\网站根目录d\cms";
echo dirname($file);

it can well done.

Expected result:
----------------
code:
$file="D:\Backup\我的文档\网站根目录d\cms";
echo dirname($file);

then it print D:\Backup;
but when I add a english character:

$file="D:\Backup\我的文档\网站根目录d\cms";
echo dirname($file);

it can well done.

Actual result:
--------------
code:
$file="D:\Backup\我的文档\网站根目录d\cms";
echo dirname($file);

then it print D:\Backup;
but when I add a english character:

$file="D:\Backup\我的文档\网站根目录d\cms";
echo dirname($file);

it can well done.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-29 19:55 UTC] 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-31 14:00 UTC] kalle@php.net
sjoerd> Thats bugsweb causing that on unicode characters, first they are converted to entities and then the & is escaped into &. So it ends up with &#XXXX; =)
 [2014-01-30 21:31 UTC] 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>
 [2017-10-17 12:30 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2017-10-17 12:30 UTC] cmb@php.net
Closing according to previous comment.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC