iconv unicode未知输入格式 [英] iconv unicode unknown input format
问题描述
$ file xxx.csv
xxx.csv :UTF-8 Unicode文本,非常长的行
查看 less
/ vi
将呈现一些特殊字符(ßÄ°...)不可读(├╝); Windows也不会显示它;将其直接导入数据库将只会将特殊字符更改为其他特殊字符(+ä,+ñ,...)。
我想立即转换使用iconv进行默认可读编码。
当我尝试用iconv转换它$ /
$ iconv -f UTF-8 -t ISO-8859-1 xxx.csv> yyy.csv
iconv:位置1234的非法输入序列
使用UNICODE作为输入和UTF -8输出将返回相同的消息
我猜这个文件有些编码为另一种格式,我不知道 - 我如何找到哪个格式的顺序将其转换为普遍可读的东西...
问题是Windows无法将文件解释为UTF- 8本身它读取为asci,然后ä成为一个2字符的解释ä(ascii 195 164)
试图转换它,我找到了一个适用于我的解决方案: / p>
iconv -f UTF-8 -t WINDOWS-1252 // TRANSLIT --output = outfile.csv inputfile.csv
现在我可以在编辑器中正确查看特殊字符
对于SQLServer的兼容性,将UTF-8转换为UTF-16将会更好的工作...只是文件大小增加了一点点
I have a file which is described under Unix as:
$file xxx.csv
xxx.csv: UTF-8 Unicode text, with very long lines
Viewing it in less
/vi
will render some special chars (ßÄ°...) unreadable (├╝); Windows will also not display it; importing it directly into a db will just change the special characters to some other special characters (+ä, +ñ, ...).
I wanted to convert it now to a "default readable" encoding with iconv. When I try to convert it with iconv
$iconv -f UTF-8 -t ISO-8859-1 xxx.csv > yyy.csv
iconv: illegal input sequence at position 1234
using UNICODE as input and UTF-8 as output will return the same message
I am guessing the file is somewhat encoded in another format which I do not know - how can I find out which format in order to convert it to something "universally" readable ...
The problem was that Windows could not interpret the file as UTF-8 on itself. it reads it as asci and then ä becomes a 2 character interpretation ä (ascii 195 164)
trying to convert it, I found a solution that works for me:
iconv -f UTF-8 -t WINDOWS-1252//TRANSLIT --output=outfile.csv inputfile.csv
now I can view the special chars correctly in editors
For SQLServer compability, converting UTF-8 to UTF-16 will work even better ... just the filesize grows quite a bit
这篇关于iconv unicode未知输入格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!