如何在Android上发送HttpPost中的unicode字符
我正在尝试在我的应用程序中提供多语言支持,可以通过HTTP post上传新消息。为了支持日语和其他非拉丁语,我需要做什么?我的代码当前看起来像这样:如何在Android上发送HttpPost中的unicode字符,android,http,unicode,post,encoding,Android,Http,Unicode,Post,Encoding,我正在尝试在我的应用程序中提供多语言支持,可以通过HTTP post上传新消息。为了支持日语和其他非拉丁语,我需要做什么?我的代码当前看起来像这样: //note the msg string is a JSON message by the time it gets here... private String doHttpPost(String url, String msg) throws Exception { HttpPost post = new H
//note the msg string is a JSON message by the time it gets here...
private String doHttpPost(String url, String msg)
throws Exception {
HttpPost post = new HttpPost(url);
StringEntity stringEntity = new StringEntity(msg);
post.setEntity(stringEntity);
return execute(post);
}
尝试在StringEntity上设置编码:
StringEntity stringEntity = new StringEntity(msg, "UTF-8");
我也有同样的问题,你能帮我吗?