首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在安卓系统的HttpPost中发送unicode字符

如何在安卓系统的HttpPost中发送unicode字符
EN

Stack Overflow用户
提问于 2011-02-23 05:54:53
回答 1查看 9K关注 0票数 15

我正在尝试在我的应用程序中允许多语言支持,它可以创建一个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 HttpPost(url);

    StringEntity stringEntity = new StringEntity(msg);
    post.setEntity(stringEntity);


    return execute(post);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-02-23 06:38:03

尝试在StringEntity上设置编码:

StringEntity stringEntity = new StringEntity(msg, "UTF-8");
票数 40
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5084462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档