我们如何解析采用 ISO-8859-15 编码的 XML?
我使用 UTF-8 编码的 xml 来使用 NSXMLParser 进行解析。但一些特殊字符引起了问题,因此决定使用 ISO-8859-15 编码。
但之后解析器甚至没有开始解析并给出错误 31 - NSXMLParserUnknownEncodingError。我现在该怎么办?无论如何,我们是否可以在 iphone 中解析 ISO-8859-15 编码的 xml? libxml 或任何其他解析器会提供对此编码的支持吗?
I was using UTF-8 encoded xml for parsing using NSXMLParser. But some of the special characters were causing problems and so decided to use ISO-8859-15 encoding.
But after that the parser doesnt even start parsing and is giving the error 31 - NSXMLParserUnknownEncodingError. What should I do now? Is it possible by anyway we can parse a ISO-8859-15 encoded xml in iphone? Will libxml or anyother parser provide support for this encoding?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己解决了这个问题。我们决定对 xml 使用 UTF-8 编码,并使用 NSXMLParser 对其进行解析。但在解析之前我们做了以下步骤。
之后,一些意大利字符(3-4)仍然引起问题,我们在得到结果后手动替换它们。
现在一切正常。
I solved this issue by myself. We decided to use the UTF-8 encoding for the xml and parsed it using the NSXMLParser. But before the parsing we did the following steps.
Then after that some italian characters(3-4) were still causing problems and we manually replaced them after getting the result.
Now everything works fine.
NISOLatin1StringEncoding 是错误的,例如 € 无法编码。
xml 文件:
xCode:
从 xml 获取字符串:(例如 USAdditions.m)
NSISOLatin1StringEncoding is wrong, e.g. € can't encode.
xml file:
xCode:
get string from xml: (e.g. USAdditions.m)