Converting Mac Roman character to equivalent UTF-8

后端 未结 4 556
旧巷少年郎
旧巷少年郎 2021-01-18 06:41

I have been given some HTML files that use the Mac OS Roman file encoding. The files have French text, but in an editor many of the diacritical chars look strange (i.e. non

4条回答
  •  野的像风
    2021-01-18 07:04

    To convert lots of old java code files in directory tree, this worked for me. Observe that the command will change files recursively in all directories from where you did cd into. Make sure you are positioned in the right directory and that you have a backup of your files, and computer, first. When you know what you are doing, correct the rm statement. Hope this can help somebody, took me hours to correct the tiny details to get this working.:

    cd /tmp  
    pwd  
    find . -name "*.java" -exec bash -c 'mv $1 $1.WXY; iconv -f MAC -t UTF8 $1.WXY > $1; rm $1.WXYY' sh {} \;
    

提交回复
热议问题