LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Special chars on filename problems with Centos and Apache (https://www.linuxquestions.org/questions/linux-general-1/special-chars-on-filename-problems-with-centos-and-apache-741679/)

jmandrak 07-21-2009 07:45 AM

Special chars on filename problems with Centos and Apache
 
Hi all,

I have a webserver runing centos and apache.
One of my client's site was hosted on Windows and I've mirrod his site using lftp.

Now I have a problem with files with accented words, like "duração.jpg", "foto do café.jpg" and others.

On the command line a "ll" shows the folowing:
duração.jpg -> dura\347\343o.jpg
foto do café.jpg -> foto\ do\ caf\351.jpg

However, the pictures does not shows correctly on the browsers, and inspecting apache's error log I could find that it's trying to load "dura\xc3\xa7\xc3\xa3o.jpg" or "foto do caf\xc3\xa9.jpg".

How could I rename all of these files? Would there be a .htaccess rewrite rule for that?

I've searched around the web today and found about the command rename. I've tried a few commands but no success, also, I'm not that good with regular expressions.

Tinkster 07-21-2009 12:48 PM

Hi, welcome to LQ!

You may be after something like this:
http://sharealike.org/index.php/2008...iles-to-utf-8/

Of course I don't know *which* actual windows encoding may
have been in use to get the Brazilian characters ...



Cheers,
Tink

jmandrak 07-21-2009 12:59 PM

Tinkster

Thanks for your link, but the problem would be the file name itselft, not it's content.

It seems that the real problem here is that browsers requests the files using UTF-16 (?).

I've been testing out this requests and while browsers fail to retrieve the files, download tools such as GetRight can grab the files perfectly.

Unfortunatelly I don't see many other solutions other than creating a script that will rename all files and replace the html contents with the new file name. This would be safer for the future, and better for the client. Also, They will have to learn with their mistake.

Tinkster 07-21-2009 01:36 PM

ok, I get it :}

Try this
http://www.j3e.de/linux/convmv/



Cheers,
Tink

jmandrak 07-21-2009 07:19 PM

Superb!!
 
Tink,

Thanks for your help! Worked like a charm!
I'll keep this convmv script for my life!

I owe you a beer man! :D Thanks a ton!

jschiwal 07-21-2009 07:20 PM

If you are working in konsole, does it help changing the encoding to utf8?

I've noticed that some commands don't play nice with these filenames.

Code:

ls dur*.jpg
dura????o.jpg

ls dur*.jpg | cat
duração.jpg

If the files are on vfat or ntfs partitions, use the "nls=utf8" mount option. Also the nls_utf8 kernel module needs to be loaded.

Tinkster 07-21-2009 07:37 PM

Quote:

Originally Posted by jmandrak (Post 3615844)
Tink,

Thanks for your help! Worked like a charm!
I'll keep this convmv script for my life!

I owe you a beer man! :D Thanks a ton!

Heh ... I'll hold you to that if I ever visit the
place where you live ;D





Cheers,
Tink


All times are GMT -5. The time now is 02:44 AM.