文件编码格式的转换之GB2312转UTF-8 Without BOM之使用iconv

在前一篇文章中《文件编码格式的转换之GB2312转UTF-8 Without BOM》:
https://blog.csdn.net/cpdoor2163_com/article/details/112260222
提到了几种GB2312转UTF-8的方法,这里还可以使用iconv完成GB2312转UTF-8的任务:
“iconv命令可以将一种已知的字符集文件转换成另一种已知的字符集文件。”

两句题外话:
WPS中,如果写入过中文,存储的表格csv文件就是GB2312编码格式的。WPS里不能存储为UTF-8格式。才有了写这2篇文章的起因。
要想知道文件的编码格式,除了记事本,VS等专业的一点的工具,QQ浏览器(QQ Browser),和Firefox浏览器,这些常用的浏览器,可以查看文件的编码格式,不过需要删除文件的后缀名。

iconv的Windows版的下载地址:
《LibIconv for Windows》
http://gnuwin32.sourceforge.net/packages/libiconv.htm
或者,在这里也可以下载,iconv的Windows版:
https://download.csdn.net/download/cpdoor2163_com/14038792

GB2312转UTF-8的方法步骤:

1.
创建ConverFile_From_GB2312_To_UTF8WithoutBOM.bat,内容如下:

iconv.exe -f GB2312 -t UTF-8 Table1_GB2312.csv > Table1_UTF8WithoutBOM.csv

从Table1_GB2312.csv生成了Table1_UTF8WithoutBOM.csv,可以看到把GB2312文件转为UTF-8 Without BOM编码格式了。

 

参考:
a.
《libiconv》
http://www.gnu.org/software/libiconv/

b.
《使用windows命令和iconv.exe批量转换文件编码》
https://www.cnblogs.com/adgnat/archive/2011/07/15/2107884.html

c.
《iconv》
https://baike.baidu.com/item/iconv/524310?fr=aladdin

d.
iconv help:
Usage: iconv.exe [OPTION...] [-f ENCODING] [-t ENCODING] [INPUTFILE...]
or:    iconv.exe -l

Converts text from one encoding to another encoding.

Options controlling the input and output format:
  -f ENCODING, --from-code=ENCODING
                              the encoding of the input
  -t ENCODING, --to-code=ENCODING
                              the encoding of the output

Options controlling conversion problems:
  -c                          discard unconvertible characters
  --unicode-subst=FORMATSTRING
                              substitution for unconvertible Unicode characters
  --byte-subst=FORMATSTRING   substitution for unconvertible bytes
  --widechar-subst=FORMATSTRING
                              substitution for unconvertible wide characters

Options controlling error output:
  -s, --silent                suppress error messages about conversion problems

Informative output:
  -l, --list                  list the supported encodings
  --help                      display this help and exit
  --version                   output version information and exit

Report bugs to <bug-gnu-libiconv@gnu.org>.

e.

《Unicode 和 UTF-8、UTF-16、UTF-32之间的关系》
https://blog.csdn.net/hongsong673150343/article/details/88584753

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值