Bug #37268 [Wfx]: basename() doesnt work with non-latin first letters of the file.
| From: | mike@php.net | Date: | Thu, 12 Mar 2015 08:39:54 +0000 |
| Subject: | Bug #37268 [Wfx]: basename() doesnt work with non-latin first letters of the file. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191341@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=37268&edit=1
ID: 37268
Updated by: mike@php.net
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
Private report: N
New Comment:
You need to set the correct locale for stdlib/multibyte functions to work correctly; anyway,
3v4l.org apparently only has C/POSIX locale available:
http://3v4l.org/M6jhm
Previous Comments:
------------------------------------------------------------------------
[2015-03-12 04:20:12] vovan-ve at yandex dot ru
Are you sure this problem will be solved? http://3v4l.org/BWgUm
------------------------------------------------------------------------
[2010-07-31 23:21:11] daniel at mameso dot com
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
------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=37268&edit=1