gpt4 book ai didi

java - Android - 用俄语单词解析 xml(编码)

转载 作者:行者123 更新时间:2023-11-30 04:16:33 26 4
gpt4 key购买 nike

我在 android 中解析 xml 文件。我复制粘贴了示例...
它适用于英语单词,但我需要让它使用俄语单词(它不适用于俄语单词 - 无一异常(exception) - 简单的错误编码)。我试着添加这个

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/

最佳答案

很简单。我从 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");

很简单,我必须立即添加编码,当我得到消息时!

关于java - Android - 用俄语单词解析 xml(编码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9896812/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com