我在android中解析xml文件。我复制了例子......
它适用于英语单词,但我需要使用俄语单词(它不会使用russion单词 - 无一例外 - 简单的错误编码)。
我试着添加这个
InputSource is = new InputSource();
is.setEncoding("UTF_8"); //add this
is.setCharacterStream(new StringReader(xml));
doc = db.parse(is);
它没有帮助我一点点
Xml采用utf-8
编码。我想,我的应用程序将utf-8中的单词翻译成windows1252 ...
有人可以帮忙吗?
感谢您的编辑!)
源代码示例 - http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/
答案 0 :(得分:1)
这很简单。 我从http://forum.sources.ru/index.php?showtopic=354149&st=15&#entry3106098得到答案 用英语讲: 我的应用程序从错误编码的xml中得到消息!
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity, "UTF-8");
简单,我必须在片刻中添加编码!
答案 1 :(得分:0)
尝试使用ISO-8859-5
编码代替UTF-8
(同样在你的帖子中写的是UTF * _ * 8 - 你确定吗???)