修复双重编码的UTF-8文件

时间:2013-09-17 15:22:14

标签: utf-8 character-encoding

所以我有这个双重编码的UTF-8文件。例如

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>

<body>
<p>this is a “testâ€Â</p>
</body>
</html>

网址:http://www.frostjedi.com/terra/scripts/demo/utf8-1.html

如果在Firefox中我查看源代码然后将其复制/粘贴到新文件中,我就会有效地撤消双重编码。例如

http://www.frostjedi.com/terra/scripts/demo/utf8-2.html

我的问题是......我怎么能通过CLI做到这一点?

我试过了:

iconv -f UTF-8 -t ISO-8859-1 utf8-1.html > utf8-3.html

但得到了这个:

iconv: illegal input sequence at position 294

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

尝试使用Windows-1252代替ISO-8859-1

这是Windows Latin-1和Latin-1之间的区别。所有浏览器,Mac和Linux,都错误地接受了Windows-Latin-1的ISO-8859-1,因为它填充了0x80-0x9F字符。

不保证一切都已解决。

相关问题