无法在cygwin中使用命令“ iconv”转换以下文件:“ udhr_deu_1901.txt”(源:https://unicode.org/udhr/d/udhr_deu_1901.txt)

时间:2018-11-08 14:42:02

标签: cygwin

我要转换文件

"udhr_deu_1901.txt" from UTF-8 to ISO-8859-1. 

我从终端收到的消息是

     "iconv: udhr_deu_1901.txt:2:7: cannot convert".

我不知道下一步该怎么做。如何将.txt文件转换为ISO-8859-1?

1 个答案:

答案 0 :(得分:0)

该文件包含一些iconv无法成功翻译的字符。

我们可以转换跳过不可翻译的字符,然后转换回UTF8 检查我们缺少哪个字符:

$ iconv -f UTF8 -t ISO-8859-1 -c udhr_deu_1901.txt > udhr_deu_1901-8859-1.txt

$ iconv -t UTF8 -f ISO-8859-1  udhr_deu_1901-8859-1.txt > udhr_deu_1901-UTF8.txt

$ diff -uN udhr_deu_1901.txt udhr_deu_1901-UTF8.txt
--- udhr_deu_1901.txt   2017-12-14 15:35:09.000000000 +0100
+++ udhr_deu_1901-UTF8.txt      2018-11-08 18:29:18.070810900 +0100
@@ -1,6 +1,6 @@
 Universal Declaration of Human Rights - German, Standard (1901)
-© 1996 – 2009 The Office of the High Commissioner for Human Rights
-This plain text version prepared by the “UDHR in Unicode”
+© 1996  2009 The Office of the High Commissioner for Human Rights
+This plain text version prepared by the UDHR in Unicode
 project, https://www.unicode.org/udhr.
 ---

所以问题是-,我认为您可以手动添加