Error on filename encoding (utf-8)

June 29, 2016 738 views
Linux Basics PHP Apache Debian

I've migrate a website from hostgator to digital ocean and I have filenames like:
11-01-03-La-Gr#U00e1fica-Completa.jpg
and in hostgator I've see it like:
11-01-03-La-Gráfica-Completa.jpg

I've tried to change it within the console like:
convmv -r -f ISO-8859-1 -t UTF-8 .
convmv -r -f ascii -t UTF-8 .
and so...
But I can't change it. I don't know what to do, the are almost 3000 files like that.
Thanks

2 comments
  • First, see what your current setting is by running the command locale , then set and export your LANG environment variable. For example in bash:

    ## look at the current locale
    locale
    ## set the local to Spanish
    LANG=es_ES.utf8
    export LANG
    ## look at the locale now
    locale
    

    NOTE: this is a temporary fix/test. If it works for you, then you'll have to do the next step and configure either your system or your account to use it.

  • I've made that, and...

    user@server:/var/www/mysite/public_html/wp-content/uploads/2013/10# locale
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_MESSAGES to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    LANG=es_ES.utf8
    LANGUAGE=
    LC_CTYPE=UTF-8
    LC_NUMERIC="es_ES.utf8"
    LC_TIME="es_ES.utf8"
    LC_COLLATE="es_ES.utf8"
    LC_MONETARY="es_ES.utf8"
    LC_MESSAGES="es_ES.utf8"
    LC_PAPER="es_ES.utf8"
    LC_NAME="es_ES.utf8"
    LC_ADDRESS="es_ES.utf8"
    LC_TELEPHONE="es_ES.utf8"
    LC_MEASUREMENT="es_ES.utf8"
    LC_IDENTIFICATION="es_ES.utf8"
    LC_ALL=
    
    user@server:/var/www/mysite/public_html/wp-content/uploads/2013/10# ls
    11-01-03-La-Gr#U00e1fica-Completa.jpg
    

    The first 3 lines are the problem? the last one? I can't figure out what is the problem.

2 Answers

Here's a summary from a solution by Sakshi's Oracle blog that works for Ubuntu:

sudo locale-gen es_ES.UTF-8
sudo dpkg-reconfigure locales

then edit /etc/default/locale and add LC_ALL and LANGUAGE with values "es_ES.UTF-8", like this

LANG=es_ES.UTF-8
LC_ALL=es_ES.UTF-8
LANGUAGE=es_ES.UTF-8

Now try the locale command again.

  • Thanks to both. Now I can see it right in terminal / console... but apache is still with the error...
    And I've added the line:

    AddDefaultCharset UTF-8
    

    or

    AddDefaultCharset es_ES.UTF-8
    

Thanks to both. Now I can see it right in terminal / console... but apache is still with the error...
And I've added the line:

AddDefaultCharset UTF-8

or

AddDefaultCharset es_ES.UTF-8
Have another answer? Share your knowledge.