Here is a quick example to show the issue:
print basename('léquipe.jpg'); // léquipe.jpg
print basename('équipe.jpg'); // quipe.jpg
How can I avoid this inconsistency, and be sure that basename()
will return me the whole file name?
Thanks
So as it turns out this seems to be a bug: https://bugs.php.net/bug.php?id=62119
If the first character is a non-ASCII character the character just disappears. If there are non-ASCII characters in the path itself it works fine.
Also what seems to be strange is that this problem only occurse for 64-bit PHP installations:
To solve this you could use a custom function as provided from a PHP manual comment:
function mb_basename($file)
{
return end(explode('/',$file));
}
Code from: "(remove) dot nasretdinov at (remove) dot gmail dot com"
Use http://php.net/manual/en/function.setlocale.php to solve this problem.
setlocale(LC_CTYPE, 'fr_FR.utf8');
print basename('léquipe.jpg'); // léquipe.jpg
print basename('équipe.jpg'); // équipe.jpg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With