[xml] how to get xmldecl encoding with SAX
- From: Petr Pajas <pajas ufal ms mff cuni cz>
- To: libxml2 <xml gnome org>
- Subject: [xml] how to get xmldecl encoding with SAX
- Date: Thu, 06 Mar 2003 16:42:03 +0100
Hi Daniel, All,
I'm having a trouble finding out a trace of the original encoding
declared in the <?xml ...?> decl with SAX. It seems to me it should be
visible as ctx->encoding from the startDocument event but the string
is null even if my XML file declares <?xml version='1.0'
encoding='iso-8859-2'?>.
(I know all data I get are utf8, I just need to remember the original
encoding to be able to write my output in the same encoding).
I'm actually using XML::LibXML::SAX perl interface to the SAX parser,
but the problem seems to be down in the libxml2 layer. To check this,
I've changed the textSAX.c program to print the encoding as follows:
/**
* startDocumentDebug:
* @ctxt: An XML parser context
*
* called when the document start being processed.
*/
static void
startDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
{
callbacks++;
if (quiet)
return;
fprintf(stdout, "SAX.startDocument(encoding(%s))\n",((xmlParserCtxtPtr) ctx)->encoding);
}
The result I get looks like
SAX.setDocumentLocator()
SAX.startDocument(encoding((null)))
...
though. Any help here?
-- Petr Pajas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]