After parsing a document, you can find the encoding in the encoding
slot of the xmlDoc
struct.
EDIT: If you use a push parser with your own SAX handler, no xmlDoc
will be built. In this case, you can get the encoding from an xmlParserCtxtPtr
via ctxt->encoding
(or maybe ctxt->input->encoding
) but only after the XML declaration has been parsed. This means that you have to call xmlParseChunk
at least once and make sure that enough data has been fed to the push parser.