"Re: [xml] serialization to UTF-16LE"

Kasimier Buchcik wrote:


I get different serialized results for text-nodes and attribute-values 
if using "xmlSaveFormatFileTo" (note that I'm using values like "öäü?").

code snippet:

node = xmlNewDocNode(doc, NULL, "foo", NULL);
xmlDocSetRootElement(doc, node);
xmlSetProp(node, "bar", "öäü?");
chnode = xmlNewDocText(doc, "öäü?");
xmlAddChild(node, chnode);
handler = xmlFindCharEncodingHandler((const xmlChar*) "UTF-16LE");

[... ]

xmlSaveFormatFileTo(outbuffer, doc, (const xmlChar*) "UTF-16LE", 0);

The resulting xml:

<?xml version="1.0" encoding="UTF-16LE"?>
<foo bar="&#xE4;&#xF6;&#xFC;">öäü?</foo>

Sorry, it has to be:

<?xml version="1.0" encoding="UTF-16LE"?>
<foo bar="&#xE4;&#xF6;&#xFC;&#x20AC;">öäü?</foo>

The attribute value is escaped, the text-nodes value not.
Since I did not found anything in the specs that states, that attribute 
values need to be excaped, although they *could* be serialized with the 
stated encoding (UTF-16LE), I'm asking for help on information; did I 
overlook something in the specs, or if this is a not intended bahaviour?
(Maby some context could be usefull: I'm just trying to implement (in 
Delphi) the w3c's saveToString method of the DOMSerializer interface).


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