I found a way to save to buffer with encoding:

xmlDocPtr xmlDoc = xmlNewDoc(BAD_CAST("1.0"));
// xmlDocSetRootElement(xmlDoc, (xmlNodePtr)node);

xmlBufferPtr buffer = xmlBufferCreate();
xmlCharEncodingHandlerPtr encodingHandler =
xmlFindCharEncodingHandler("UTF-8");
xmlOutputBufferPtr buf = xmlOutputBufferCreateBuffer(buffer,
encodingHandler);
int ret = xmlSaveFormatFileTo(buf, xmlDoc, "UTF-8", 0);
// xmlBufferContent(buffer);
// xmlBufferLength(buffer);
xmlBufferFree(buffer);
xmlFreeDoc(xmlDoc);

I'm using Windows OS, Is this the best way to save to buffer with encoding?



On Fri, Jun 7, 2013 at 4:42 PM, Alexwell Sandro <alexwel...@gmail.com>wrote:

> Hi, how to set xmlDocPtr encoding type?
>
> I tried this:
>
> *xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");*
> *doc->encoding = BAD_CAST "UTF-8";*
>
> When I call: *"xmlFreeDoc(doc);"* Error occurs.
>
>
> Thanks,
>
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt@gnome.org
https://mail.gnome.org/mailman/listinfo/xslt

Reply via email to