go http 请求解析body err: invalid ch
2021-02-24 本文已影响0人
五岁小孩
go http 请求解析body err: invalid character 'ï' looking for beginning of value
-
错误
http 请求解析body出错:
invalid character 'ï' looking for beginning of value
-
原因
The server is sending you a UTF-8 text string with a Byte Order Mark (BOM). The BOM identifies that the text is UTF-8 encoded, but it should be removed before decoding.
-
解决
在unmarshal之前将服务器返回的body处理一下:
// Or []byte{239, 187, 191} body = bytes.TrimPrefix(body, []byte("\xef\xbb\xbf"))