zoukankan      html  css  js  c++  java
  • 关于字符编码的问题

    在一个activity里面有一个文本输入框,我在后台通过
    EditText et_username = (EditText) findViewById(R.id.username);
    String username = new String(et_username.getText().toString());
    这样拿到的字符串不是utf-8.我尝试这样:
    username = new String(et_username.getText().toString().getBytes("UTF-8"));
    拿到的字符串依然不是utf-8希望牛人赐教怎么能够从activity获取utf-8字符集的字符串?

    String keyword = new String(keyword_EditText.getText()
                                    .toString().getBytes("UTF-8"));
                            keyword = URLEncoder.encode(keyword_EditText.getText().toString());

    httpost = new HttpPost(API_DefaultURL.replace("{0}", _page));
                    httpost.setHeader("Content-Type", "text/plain; charset=utf-8");
                    StringEntity entity = new StringEntity(strdata);
                    httpost.setEntity(entity);
                    DefaultHttpClient client = new DefaultHttpClient();
                    HttpResponse response = client.execute(httpost);
                    source = EntityUtils.toString(response.getEntity(), "UTF-8");

  • 相关阅读:
    转C#与CSV
    转Log4Net配置
    转sp_addlinkedserver实现远程数据库链接
    HTML DOM
    JavaScript学习
    2016年的个人计划-xiangjiejie
    sass转换为css
    返回上一页显示上次操作后的界面
    angular ng-bind-html 对src路径失效 解决方案
    angular json转义html
  • 原文地址:https://www.cnblogs.com/myphoebe/p/2314859.html
Copyright © 2011-2022 走看看