2025-05-23

 

1、Android -> Http Server 組件,比如servlet.

 

第一種:在HttpEntity時提供編碼,如:

HttpEntity entity = new UrlEncodedFormEntity(params,"GB2312");

第二種:在發送前對數據進行編碼,如:

java.net.URLEncoder.encode(message,"GB2312");

服務器端接收時:

String message = new String (request.getParameter("message").getBytes("iso-8859-1"),"GB2312" )

 

 

2、Http Server 比如servlet -> Android

 

String  message = "我的測試消息";

HttpServer 發送時:

message=new  String(message.getBytes("GB2312"),"ISO-8859-1");

android 接收時:

message=new  String(message.getBytes("ISO-8859-1"),"GB2312");  

 

作者 jemlee2002

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *