使用 iconv 命令将 utf8 转换为 ISO8859-1

convert utf8 to ISO8859-1 using iconv command

我想将一些 utf8 文件(文本文件)转换为 ISO-8859-1 文件。我使用这个命令行:

iconv -c -f UTF-8 -t ISO8859-1 input_file > output_file

创建的文件(output_file)确实采用了新编码,即使是重音字母也很好。

只有一个字符不是:撇号...不是对应于键 4 上显示的字符,而是类似于您可以在 word 文件中使用的字符。

问题是它被转换为一个 SUB 字符,就像你在 notepad++ 中打开一个 word 文件时看到的那样。

 (I copy the SUB here seen in notepad++ and it displays like that, obviously invisible when I submit this page)

在 notepad++ 中,有一个菜单选项可以将文件从一种编码转换为另一种编码。任何角色都没有问题。 Unix 中是否有类似的东西可以完成这项工作?

谢谢

嗯,在用 iconv 转换之前,您可以用其他东西(下面的 ')替换 ,例如:

echo Frank’s ’ | sed "s/’/'/g" | iconv -f utf8 -t iso8859-1
Frank's '

要像这样转换文件:

sed "s/’/'/g" input_file | iconv [your params here] > output_file