mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
Introduce XML_INPUT_HAS_ENCODING flag for xmlParserInput which is set when xmlSwitchEncoding is called. The parser can use the flag to reliably detect whether an encoding was already set via user override, BOM or other auto-detection. In this case, the encoding declaration won't be used to switch the encoding. Before, an inscrutable mix of ctxt->charset, ctxt->input->encoding and ctxt->input->buf->encoder was used. Introduce private helper functions to switch encodings used by both the XML and HTML parser: - xmlDetectEncoding which skips over the BOM, allowing to remove the BOM checks from other encoding functions. - xmlSetDeclaredEncoding, replacing htmlCheckEncodingDirect, which warns about encoding mismatches. If users override the encoding, store the declared instead of the actual encoding in xmlDoc. In this case, the actual encoding is known and the raw value from the doc is more useful. Also use the input flags to store the ISO-8859-1 fallback state. Restrict the fallback to cases where no encoding was specified. (The fallback is only useful in recovery mode and these days broken UTF-8 is probably more likely than ISO-8859-1, so it might eventually be removed completely.) The 'charset' member of xmlParserCtxt is now unused. The 'encoding' member of xmlParserInput is now unused. The 'standalone' member of xmlParserInput is renamed to 'flags'. A new parser state XML_PARSER_XML_DECL is added for the push parser.
52 lines
1.5 KiB
C
52 lines
1.5 KiB
C
#ifndef XML_PARSER_H_PRIVATE__
|
|
#define XML_PARSER_H_PRIVATE__
|
|
|
|
#include <libxml/parser.h>
|
|
#include <libxml/xmlversion.h>
|
|
|
|
/**
|
|
* XML_VCTXT_DTD_VALIDATED:
|
|
*
|
|
* Set after xmlValidateDtdFinal was called.
|
|
*/
|
|
#define XML_VCTXT_DTD_VALIDATED (1u << 0)
|
|
/**
|
|
* XML_VCTXT_USE_PCTXT:
|
|
*
|
|
* Set if the validation context is part of a parser context.
|
|
*/
|
|
#define XML_VCTXT_USE_PCTXT (1u << 1)
|
|
|
|
#define XML_INPUT_HAS_ENCODING (1u << 0)
|
|
#define XML_INPUT_AUTO_ENCODING (7u << 1)
|
|
#define XML_INPUT_AUTO_UTF8 (1u << 1)
|
|
#define XML_INPUT_AUTO_UTF16LE (2u << 1)
|
|
#define XML_INPUT_AUTO_UTF16BE (3u << 1)
|
|
#define XML_INPUT_AUTO_OTHER (4u << 1)
|
|
#define XML_INPUT_8_BIT (1u << 4)
|
|
|
|
XML_HIDDEN void
|
|
xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra);
|
|
XML_HIDDEN void
|
|
xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);
|
|
XML_HIDDEN void LIBXML_ATTR_FORMAT(3,0)
|
|
xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|
const char *msg, const xmlChar *str1, const xmlChar *str2);
|
|
XML_HIDDEN void
|
|
__xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
|
|
const char *msg, const xmlChar *str1,
|
|
const xmlChar *str2) LIBXML_ATTR_FORMAT(3,0);
|
|
XML_HIDDEN void
|
|
xmlHaltParser(xmlParserCtxtPtr ctxt);
|
|
XML_HIDDEN int
|
|
xmlParserGrow(xmlParserCtxtPtr ctxt);
|
|
XML_HIDDEN void
|
|
xmlParserShrink(xmlParserCtxtPtr ctxt);
|
|
|
|
XML_HIDDEN void
|
|
xmlDetectEncoding(xmlParserCtxtPtr ctxt);
|
|
XML_HIDDEN void
|
|
xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding);
|
|
|
|
#endif /* XML_PARSER_H_PRIVATE__ */
|