Android Java UTF-8 HttpClient Problem

后端 未结 5 2203
自闭症患者
自闭症患者 2020-12-01 04:35

I am having weird character encoding issues with a JSON array that is grabbed from a web page. The server is sending back this header:

Content-Type text/javascri

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 05:37

    Try this:

    if (entity != null) {
        // A Simple JSON Response Read
        // InputStream instream = entity.getContent();
        // String jsonText = convertStreamToString(instream);
    
        String jsonText = EntityUtils.toString(entity, HTTP.UTF_8);
    
        // ... toast code here
    }
    

提交回复
热议问题