X3 Photo Gallery Support Forums

Topic Author
Posts: 1
Joined: 17 Feb 2021, 15:06

A problem about the folder

18 Feb 2021, 01:55

I find it dosn't list items corrently

In ,It has $file = basename($path);
But "basename" doesn't seem to work well in a foreign language,so I get a wrong list

I add "setlocale(LC_ALL, 'zh_CN.UTF8');" into index.php and it works on Chinese
User avatar
X3 Wizard
Posts: 12635
Joined: 30 Sep 2006, 03:37

Re: A problem about the folder

18 Feb 2021, 03:16

But is it solved now after setting locale? We use PHP basename() to get the name of the directory. As stated in their docs:
PHP basename() wrote:basename() is locale aware, so for it to see the correct basename with multibyte character paths, the matching locale must be set using the setlocale() function.
So if you are using folder names with multi-byte characters, and your server default locale is not set to UTF-8, you would have to setlocale() in PHP. I may have to see if there are any workarounds to make it future-proof for all character sets.