Edit report at http://bugs.php.net/bug.php?id=37268&edit=1
ID: 37268 Comment by: daniel at mameso dot com Reported by: spam dot bugs dot php dot net at vano dot org Summary: basename() doesnt work with non-latin first letters of the file. Status: Wont fix Type: Bug Package: Filesystem function related Operating System: Fedora Core 4 PHP Version: 5.1.2 Block user comment: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2006-05-02 00:55:17] judas dot iscariote at gmail dot com you have to wait PHP6, it will address this problems. ------------------------------------------------------------------------ [2006-05-01 23:56:42] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=37268&edit=1