Linux not interpreting UTF8 encoded characters

So, having the following file Adán-y-Eva-50x50.jpg when I try to access it, apache translates it to Ad\xc3\xa1n-y-Eva-50x50.jpg and won't find it, even though it exists.

This happens only for filenames that contain UTF8 characters.

I have already the following configuration in my /etc/httpd/conf/httpd.conf

...
AddDefaultCharset UTF-8
...
IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable +Charset=UTF-8
...

And added also this to my root .htaccess on the first line:

IndexOptions +Charset=UTF-8

All this with no effect to load those kind of files. Any suggestions?

UPDATE

Just to mention it: I'm running the websites on a CentOS server with plesk panel preconfigured


Solution 1:

The problem here doesn't seem to be on your browser nor your Apache configuration. You need to double check the locale settings of your system.

You need to check if the locale apache is running is UTF-8 enabled. To do so you may run the command:

$ sudo su -l -c locale www-data

where www-data is the apache user. Check if the locale returned doesn't looks like, for example, es_ES.UTF-8 it means your locale doesn't have UTF-8 enabled.

If this is the case, you may change this configuration, on a CentOS machine, at /etc/sysconfig/i18n, changing the line LANG="es_ES" to LANG="es_ES.UTF-8". But, still, in order for this to work, your system need the locale file for this language. To check if it existes, use locale -a to get a list of locales available.

If your system doesn't have a UTF-8 enabled locale, you may generate one using the command:

$ sudo localedef -i es_ES -f UTF-8 es_ES.utf8 

and set it as your default language.

Hope this help!

Solution 2:

In addition to fboaventura's answer

Check if the locale apache is running

$ sudo su -l -c locale www-data

In order to change i18n configuration at /etc/sysconfig/i18n :

Go to the CentOS system configuration directory

$ cd /etc/sysconfig

Make backup copy of your language setting file

$ cp i18n i18n.backup

Edit language setting file by using nano

$ nano i18n

Edit the file to include your configuration

For example:

LANG="en_US.utf8"
SYSFONT="latarcyrheb-sun16"
SUPPORTED="en_US.utf8:en_US:en:fr_FR.utf8:fr_FR:fr :es_ES.utf8:es_ES:es:de_DE.utf8:de_DE:de:sv_SE.utf 8:sv_SE:sv:zh_CN.utf8:
zh_CN:zh:zh_TW.utf8:zh_TW:zh:ja_JP.utf8:ja_JP:ja:k o_KR.utf8:ko_KR:ko"

Save the file and restart the system.

Additional Resources

  • https://unix.stackexchange.com/questions/74618/how-to-change-locale-environment-variable
  • How to change my commandline locale after CentOS decided to change it?