Re: [xml] xmlWriter and Encoding

Steffen Barszus schrieb:
Hi !

I'm currently writing an application which is reading XML and writing formatted Text to a file. I'm still in the process to learn C/C++, so forgive me if i'm asking stupid questions ;)

For the app i use the XmlReader and XmlWriter. Based on environment i want to write the file in system encoding. For testing i used this:

       writer = xmlNewTextWriterFilename("test.epg", 0);
       if (writer == NULL) {
printf("testXmlwriterFilename: Error creating the xml writer\n");
           return -27;
       xmlTextWriterStartDocument(writer, NULL,"iso-8859-1",NULL);

I would like to use a similar simple way to set the encoding for the written document, but as i don't write XML i don't need/can't have the XML declaration in the output.

Is there any simple way of setting the encoding without writing the declaration ?
Nevermind, found it myself in the meantime :) Just for the record:

encoder = xmlFindCharEncodingHandler("iso-8859-1"); // get the encoder outdocbuffer = xmlOutputBufferCreateFilename ("test.epg", encoder, 0); // initialize the output with encoder
       writer = xmlNewTextWriter(outdocbuffer); // write to the output

Of course plus some error checking, just schematic.

Thanks !

Kind Regards


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