Re: [xml] libxml2, howto force encoding



  Now to go back to the original question, yes I think this is
possible but it's not easy. You must create a parser input
indicating the encoding to use (xmlIO.h), create a parser context,
use that parser input to that parsed context and then ask to parse
the document. Not trivial, look at xmlCreateFileParserCtxt() code
to see how to proceed except you have to give an encoding when
creating the input stream.

thx :)
i have solved the problem in the following way:

xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt( filename);
xmlSwitchEncoding( ctxt, XML_CHAR_ENCODING_8859_1);
xmlParseDocument( ctxt);
xmlNodePtr cur = xmlDocGetRootElement( ctxt->myDoc);

...and so on
this is working for me ;)

Bye
Matthias Knoefel










[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]