|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-01 23:56 UTC] spam dot bugs dot php dot net at vano dot org
Description: ------------ If a file starts with a non-latin letter (cyrillic) and not with a non-letter character, basename will cut off the beginning of name untill a latin letter or a non-letter character found in the name. In my tests I was using Windows-1251 (CP1251) encoding and not UNICODE, so, the problem is in basename() function itself not in multi-byte charsets. P.S. if you have problem with text encoding of the example below, you can see a realtime example and test your own inputs there: http://examples.vano.org/basename.php Reproduce code: --------------- <?php echo basename("/test/blah/music/???????latin.mp3"); ?> Expected result: ---------------- ???????latin.mp3 Actual result: -------------- latin.mp3 PatchesUTF8 (last revision 2011-05-18 08:18 UTC by vsz at ya dot ru)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 16:00:01 2025 UTC |
a workaround: # workaround for splitting basename whith beginning utf8 multibyte char function mb_basename($filepath, $suffix = NULL) { $splited = preg_split ( '/\//', rtrim ( $filepath, '/ ' ) ); return substr ( basename ( 'X' . $splited [count ( $splited ) - 1], $suffix ), 1 ); } have fun, Daniel. PS: the problem does not exist under MAC OSX 10.6.x with ZendServerCE 5.0 & PHP5.3