curl乱码详解程序员

curl url返回的内容乱码
这里写图片描述
使用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
这里写图片描述

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/tech/aiops/1223.html

(0)
上一篇 2021年7月15日 22:46
下一篇 2021年7月15日 22:46

相关推荐

发表回复

登录后才能评论