[.NET] XmlTextWriter, StringWriter a zmena kódovania
mám metódu:
function TTemplate.GetChangedControls: string;
var
Xml: XmlTextWriter;
StringText: StringWriter;
begin
Result := '';
StringText := StringWriter.Create;
Xml := XmlTextWriter.Create(StringText);
try
Xml.WriteStartDocument;
Xml.WriteStartElement('controls');
Xml.WriteStartElement('control');
Xml.WriteAttributeString('id', 'test');
Xml.WriteCData('<button >');
Xml.WriteEndElement;
Xml.WriteEndElement;
Xml.WriteEndDocument;
finally
Xml.Flush;
Xml.Close;
Result := StringText.ToString;
end;
end;
a na výstupe dostanem:
<?xml version="1.0" encoding="utf-16"?>
<controls>
<control id="test"><![CDATA[<button >]]></control>
</controls>
ako mám zmeniť kódovanie XML dokumentu z UTF16 na UTF8 ?