我有一个文本文件,其中的字符编码很奇怪,我想将其转换为标准 UTF-8。我已设法完成了部分工作:
$ file myfile.txt
myfile.txt: Non-ISO extended-ASCII text, with LF, NEL line endings
$ iconv -f ascii -t utf-8 myfile.txt > myfile.txt.utf8
$ file myfile.txt.utf8
myfile.txt.utf8: UTF-8 Unicode text, with LF, NEL line endings
## edit myfile.txt.utf8 using nano, to fix failed character conversions (mostly åäö)
$ file myfile.txt.utf8
myfile.txt.utf8: UTF-8 Unicode text, with LF, NEL line endings
但是,我不知道如何转换行尾。如何用 CR+LF(或任何标准)替换 LF+NEL?完成后,我希望看到以下内容:
$ file myfile.txt
myfile.txt: UTF-8 Unicode text
答案1
试试吧iconv -f cp850 -t utf-8
。可能会对你有帮助