[PATCH v4 3/3] msxml3: When saving XML use encoding specified in the processing instruction.
Nikolay Sivov
nsivov at codeweavers.com
Thu May 27 01:06:47 CDT 2021
On 5/20/21 9:50 AM, Dmitry Timoshkov wrote:
> +static char *xmldoc_encoding(IXMLDOMDocument3 *doc)
> +{
> + HRESULT hr;
> + IXMLDOMNode *node;
> + char *encoding = NULL;
> +
> + hr = IXMLDOMDocument3_get_firstChild(doc, &node);
> + if (hr == S_OK)
> + {
> + DOMNodeType type;
> +
> + hr = IXMLDOMNode_get_nodeType(node, &type);
> + if (hr == S_OK && type == NODE_PROCESSING_INSTRUCTION)
> + {
> + IXMLDOMProcessingInstruction *pi;
> + IXMLDOMNode *item;
> + IXMLDOMNamedNodeMap *node_map;
> +
> + hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMProcessingInstruction, (void **)&pi);
> + if (hr == S_OK)
> + {
> + hr = IXMLDOMNode_get_attributes(node, &node_map);
> + if (hr == S_OK)
> + {
> + static const WCHAR encodingW[] = {'e','n','c','o','d','i','n','g',0};
> + BSTR bstr;
> +
> + bstr = SysAllocString(encodingW);
> + hr = IXMLDOMNamedNodeMap_getNamedItem(node_map, bstr, &item);
> + SysFreeString(bstr);
> + if (hr == S_OK)
> + {
> + VARIANT var;
> +
> + hr = IXMLDOMNode_get_nodeValue(item, &var);
> + if (hr == S_OK)
> + {
> + if (V_VT(&var) == VT_BSTR)
> + encoding = (char *)xmlchar_from_wchar(V_BSTR(&var));
> +
> + VariantClear(&var);
> + }
> + }
> +
> + IXMLDOMNamedNodeMap_Release(node_map);
> + }
> +
> + IXMLDOMProcessingInstruction_Release(pi);
> + }
> + }
> +
> + IXMLDOMNode_Release(node);
> + }
> +
> + return encoding;
> +}
Why all this complexity? Isn't it the same as reading current "encoding"
value from artificially linked PI node?
More information about the wine-devel
mailing list