任何人都有一个巧妙的技巧如何在Linux(Ubuntu)中将大量的php和html文件从UTF-8转换为ISO-8859-1?
Ubuntu已重新编码
$ sudo apt-get install recode $ recode UTF-8..latin1 *.php
递归地,感谢Ted Dziuba:
$ find . -name "*.php" -exec recode UTF-8..latin1 {} \;
我认为iconv是你的答案......
表格人iconv:
NAME iconv - Convert encoding of given files from one encoding to another SYNOPSIS iconv -f encoding -t encoding inputfile DESCRIPTION The iconv program converts the encoding of characters in inputfile from one coded character set to another. The result is written to standard output unless otherwise specified by the --output option. .....
所以你可以做一个
find $my_base_dir -name "*.php" -o -name "*.html" -exec sh -c "( \ iconv -t ISO88592 -f UTF8 {} -o {}.iconv ; \ mv {}.iconv {} ; \ )" \;
这将递归地找到适当命名的文件并重新编码它们(临时文件是必需的,因为iconv将在开始工作之前截断输出).