Using iconv to convert from UTF-16BE to UTF-8 without BOM

∥☆過路亽.° 提交于 2019-12-10 02:15:52

问题


I'm trying to convert a UTF-16BE encoded file (byte order mark: 0xFE 0xFF) to UTF-8 using iconv like so:

iconv -f UTF-16BE -t UTF-8 myfile.txt

The resulting output, however, has the UTF-8 byte order mark (0xEF 0xBB 0xBF) and that is not what I need. Is there a way to tell iconv (or is there an equivalent encoding) to not put a BOM in the UTF-8 result?


回答1:


Experiment shows that indicating UTF-16 rather than UTF-16BE does what you want:

iconv -f UTF-16 -t UTF-8 myfile.txt


来源:https://stackoverflow.com/questions/11571665/using-iconv-to-convert-from-utf-16be-to-utf-8-without-bom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!