curl url返回的内容乱码

curl乱码_sed


使用iconv命令可以解决乱码问题

curl url|iconv -f gb2312 -t utf8

iconv
-f(rom)指定来源编码,-t(o)转化的编码

-f fromcodeset 
 Identify the codeset of the input file. The implementation shall recognize the following two forms 
 of the fromcodeset option-argument:-t tocodeset 
 Identify the codeset to be used for the output file. The implementation shall recognize the follow‐ 
 ing two forms of the tocodeset option-argument:

实践得知,只需要指定源文件的编码就能修正乱码问题。如果控制台通过其他编码显示则再加上-t

curl乱码_编码_02