解析rss和atom文件出现乱码问题

        try {
            String xmlString = new String(response.data, Charset.forName("UTF-8"));
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            XmlPullParser xmlPullParser = factory.newPullParser();
            xmlPullParser.setInput(new StringReader(xmlString));
            return Response.success(xmlPullParser, HttpHeaderParser.parseCacheHeaders(response));
        } catch (XmlPullParserException e) {
            return Response.error(new ParseError(e));
        }

Charset字符集指定utf-8,将返回的字符串重新编码就不会出现乱码了

posted @ 2016-03-27 12:50  Leo的银弹  阅读(370)  评论(0编辑  收藏  举报