A Chinese language user reported problems with folder names outputting wrong name if there are mixed characters (Chinese + latin). This is caused by encoding and PHP basename(), which might fail if encoding does not match locale. I already looked into this, and the solution seemed to be to force UTF-8
, already added to index.php
:
setlocale(LC_ALL,'en_US.UTF-8');
However, this does not always seem to solve the problem. There is another solution, that simply users a different function to extract the basename of a path. Find the following in index.php
(currently around line 432
):
function _basename($path){
return basename($path); // because setlocale(LC_ALL,'en_US.UTF-8')
// OPTIONAL: replace basename() which may fail on UTF-8 chars if locale != UTF8
// $arr = explode('/', str_replace('\\', '/', $path));
// return end($arr);
}
Comment out the first line, and un-comment the two bottoms lines:
function _basename($path){
// return basename($path); // because setlocale(LC_ALL,'en_US.UTF-8')
// OPTIONAL: replace basename() which may fail on UTF-8 chars if locale != UTF8
$arr = explode('/', str_replace('\\', '/', $path));
return end($arr);
}
The above function will use a different method to extract the basename of the path.