|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29542 basename() has problem in supporting multi-byte chars.
Submitted: 2004-08-05 23:42 UTC Modified: 2004-09-04 17:49 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ppmm at wuxinan dot net Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5.0.0 OS: Windows 2000 Prof.
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ppmm at wuxinan dot net
New email:
PHP Version: OS:


 [2004-08-05 23:42 UTC] ppmm at wuxinan dot net
when path has multi-byte chars, basename() does not return correct file basename. I did not have this problem in PHP 4.3.7. In the example, $hehe variable has two gb2312-encoded chinese chars. This might relate to setlocale or something like that.

Reproduce code:
$hehe = "hehe/?պ? haha kkk";
echo basename($hehe)."\n";
echo substr($hehe, strrpos($hehe, "/")+1);

Expected result:
?պ? haha kkk
?պ? haha kkk

Actual result:
 haha kkk
?պ? haha kkk


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-04 17:16 UTC]
Please try using this CVS snapshot:
For Windows:

Works fine here, try the latest snapshot.
 [2004-09-04 17:45 UTC] ppmm at wuxinan dot net
didn't try CVS, but quickly tried 5.0.1 and found no problem. This bug must have been fixed in 5.0.1 already. Thanks.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Oct 01 20:05:53 2022 UTC