[xml] Retrieve encoding from xml input document (ctxt->encoding)
- From: Olivier Courtin <olivier courtin pnine org>
- To: xml gnome org
- Subject: [xml] Retrieve encoding from xml input document (ctxt->encoding)
- Date: Thu, 4 Dec 2003 14:43:30 +0100
Hello,
I've got a little problem with libxml2 as i want to retrieve encoding
type from xml input document.
Here a little test code :
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
int main(int argc, char * argv[]){
xmlParserCtxtPtr ctxt;
ctxt = xmlCreateFileParserCtxt(argv[argc - 1]);
if (ctxt == NULL) return EXIT_FAILURE;
xmlParseDocument(ctxt);
printf("[%s]\n", ctxt->version);
printf("[%s]\n", ctxt->encoding);
xmlFreeParserCtxt(ctxt);
return EXIT_SUCCESS;
}
Compilation line :
gcc -Wall -ansi -pedantic -g `xml2-config --cflags` test.c -o test
`xml2-config --libs`
xml2-config --version -> 2.6.2
And if i launch the test program on an xml document, i retrieve
correctly the xml version number, but *not* the encoding. Except when
encoding is UTF-8. On other case (ISO-8859-1, US-ASCII...)
ctxt->encoding is a NULL pointer.
I've read doc, and several mails from this mailing list about encoding,
but none seems helpfull in this case.
I also play with DEBUG_ENCODING from encoding.c and in all cases the
encoding handler founded is right.
So i surely miss something, as i believe it's a common task...
Any help would be appreciate :)
--
Ol
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]