EntityUtils.toString(entity,"UTF-8");无返回中文都乱码
查尔斯风 2017-09-30 04:56:13 HttpPost httppost = new HttpPost(location);
HttpEntity re = new StringEntity(reqData, HTTP.UTF_8);
setHeaders(httppost, headerType);//设置header utf-8方法
httppost.setEntity(re);
HttpResponse response = httpClient.execute(httppost);
result = EntityUtils.toString(response.getEntity(),"UTF-8");
------------------------------
result 乱码(无论是否有中文)。各种格式尝试过了,gbk也不行。
网上找到3种转格式方法试过了,也没用(
1、EntityUtils.toString(response.getEntity(),"GBK");
2、new String(EntityUtils.toString(response.getEntity()).getBytes("ISO-8859-1"),"GBK");
3、new String(result.getBytes("ISO-8859-1"),"GBK");)。
大神们,看看还有什么办法,搞定这个乱码问题