简体   繁体   English

POCO C ++ SAX解析器:如果xml文档编码为ANSI,则next语句未读取并抛出编码错误异常

[英]POCO C++ SAX parser: If the xml document encoding is ANSI then next statement is not reading and throwing encoding error exception

Suppose the following is the xml document then hello tag is not reading by the poco sax parser because of encoding is ANSI. 假设以下是xml文档,则由于编码是ANSI,因此poco sax解析器无法读取hello标签。

<?xml version="1.0" encoding="ANSI"?>
<hello xmlns="  ">

If the encoding is UTF-8 then hello tag is reading and everything is went fine. 如果编码为UTF-8,则hello标签正在读取,一切正常。

Is there any solution in POCO for this issue? POCO中有针对此问题的任何解决方案吗?

It's not a POCO problem, fix the producer. 解决生产商问题不是POCO问题。 There's no such thing as "ANSI" encoding in XML. XML中没有“ ANSI”编码之类的东西。 The producer should generate output in a valid encoding. 生产者应以有效编码生成输出。 Whether that's "UTF-8" or "ISO-8859-1" doesn't really matter, as long as it's all consistent. 只要是一致的,那是“ UTF-8”还是“ ISO-8859-1”并不重要。

The encoding problem arise if you specify a encoding but you use a different encoding, source of trouble could arise (in example) if you copy-paste a XML source between multiple documents, from webpages, or simply because it has a buggy encoder. 如果您指定编码但使用不同的编码,则会出现编码问题,例如,如果您在多个文档之间,从网页中复制粘贴XML源,或者仅仅是因为它具有错误的编码器,则可能会引起麻烦(例如)。 Try to use some program that can detect encoding and change that, set it to UTF8 and then replace the header tag for ANSI wich the one for UTF8. 尝试使用一些可以检测编码并对其进行更改的程序,将其设置为UTF8,然后将ANSI的标头标记替换为utf8的标头标记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM