[xml] How to create a UTF-8 XML document (in-memory)



Hello World, hello Daniel,

I'm creating a XML document using

xmlProg = xmlNewDoc("1.0");

Then I add nodes and subnodes, finally I'll dump the complete document to a buffer:

xmlDocDumpMemory(xmlProg, &xmlStr, &xmlStrLen, "UTF-8");


My problem: I have node values containing umlauts (for example: "Früchte"). Although I specify "UTF-8" as 
encoding and altough I use xmlEncodeSpecialChars(xmlProg, "Früchte"), at the time I use it, the encoding is 
not yet specified and if I write the buffer to a file, the BOM is written, but the actual encoding is cp1252 
(I'm woring on windows). And if I try to read the document again, libxml2 complains that the document is not 
UTF-8, which is correct (the "ü" in "Früchte" has a value with bit 8 set)

I know that the internal encoding is UTF-8, but how do I tell that my XML document and how do I have to 
convert the characters/strings to make it correct?

Used library: libxml2 2.6.27

Best Regards
        Andreas
-- 
Andreas Tscharner                      andreas tscharner metromec ch
--------------------------------------------------------------------
"You take the blue pill and the story ends. You wake in your bed and
 believe whatever you want to believe. You take the red pill and you
 stay in Wonderland and I show you how deep the rabbit-hole goes."
                                               -- Morpheus in Matrix



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