HttpGet执行后的一些未知字符 - ANDROID

时间:2014-08-05 17:37:43

标签: android url character-encoding http-get

我用Google搜索了几个小时,检查了stackoverflow帖子几个小时但没有结果:

我的代码是:

    String result = null;
    DefaultHttpClient httpclient = new DefaultHttpClient();
    HttpGet request = new HttpGet("some site here");
    request.addHeader("Content-Type","text/html; charset=iso-8859-15");
    HttpResponse response = null;
    try {
        response = httpclient.execute(request);
        BufferedReader in;
        in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    StringBuffer sb = new StringBuffer("");
    String line = "";
    while ((line = in.readLine()) != null) {
        sb.append(line);
    }
    in.close();
    result = sb.toString();
    } catch (IOException e) {
        e.printStackTrace();
    }

但是在下面的图片中打印出字符串结果(我的页面)的内容后,两个法语字符(é&è)无法识别:

enter image description here

注意:浏览器可以很好地识别这些字符

请问如何解决这个问题? 谢谢

0 个答案:

没有答案