关于字符编码的问题

在一个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");

posted @ 2012-01-06 16:40  tokeep  阅读(163)  评论(0编辑  收藏  举报