我尝试通过json发送日语字母,但是返回的json值是"jspString":"???????"
。我究竟做错了什么?谢谢!
JSONObject info = new JSONObject();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
info.put("japString", "よやかなゆひま");
nameValuePairs.add(new BasicNameValuePair("info", info.toString()));
postCard.setEntity(new UrlEncodedFormEntity(nameValuePairs));
postResponse = postCardClient.execute(postCard);
postResponseEntity = postResponse.getEntity();
String printResult = EntityUtils.toString(postResponseEntity);
答案 0 :(得分:1)
找到答案:只需将toString()添加到info.put("japString", "よやかなゆひま".toString());
即可。在内部,它逃脱了unicode角色。
答案 1 :(得分:-1)
只需使用postCard.setEntity(new UrlEncodedFormEntity(nameValuePairs,“UTF-8”))代替 希望这会有所帮助