1、Android -> Http Server 组件,比如servlet.
第一种:在HttpEntity时提供编码,如:
HttpEntity entity = new UrlEncodedFormEntity(params,"UTF-8");
第二种:在发送前对数据进行编码,如:
java.net.URLEncoder.encode(message,"UTF-8");
服务器端接收时:
String message = new String (request.getParameter("message").getBytes("iso-8859-1"),"UTF-8" )
2、Http Server 比如servlet -> Android
String message = "我的测试消息";
HttpServer 发送时:
message=new String(message.getBytes("UTF-8"),"ISO-8859-1");
Android 接收时:
message=new String(message.getBytes("ISO-8859-1"),"UTF-8");