<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"><span style="white-space:pre"> </span>最近在写一个Android项目,其中要用到HttpClient。不论是使用HttpGet,还是HttpPost,访问服务器的返回数据中,所有的中文均为乱码。试过多种方法均不能转码成功显示。</span>
试过的方法有以下几种:
1、使用URLEncoder.encode(str,"utf-8")对包含乱码的字符串str进行转码。
2、使用URLDecoder.decode(str,"utf-8")对包含乱码的字符串str进行转码。
3、将字符串str转换字符格式,然后将字符数组的每个字符取出进行转码。