3
如何在字符串中轉義字符「ü」。Android post請求轉義字符
我有我的JSON數據這個角色:
{"Name": "Hyüsin"}
,當我在我的Android的網絡服務器做HttpPost。它給我一個「錯誤的請求」錯誤作爲迴應。
HttpPost代碼:
// uploads the data
public class UploadData extends AsyncTask<String, Integer, Boolean> {
@Override
protected Boolean doInBackground(String... url) {
try {
HttpPost request = new HttpPost(LogInActivity.SERVICE_URI + url[0]);
request.setHeader("Content-type", "application/json; charset=utf-8");
//THIS IS {"Name": "Hyüsin"}
JSONObject jsonTaakkaart = taakkaart.serializeToObj();
StringEntity entity = new StringEntity(jsonTaakkaart .toString());
request.setEntity(entity);
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
你是我的英雄=) – user1264255 2012-04-17 15:10:55