在Delphi 10.1柏林上,我正在使用xml来存储数据。 要写入数据,我正在使用以下代码:
xmlDocument := NewXMLDocument();
xmlDocument.Encoding := 'UTF-8';
xmlDocument.options :=[doNodeAutoIndent];
xmlDocument.Active := true;
oNode.SetAttributeNS('Text','','é');
//...
xmlDocument.SaveToStream(aStream);
要读取数据,我正在使用以下代码:
xmlDocument:= NewXMLDocument();
xmlDocument.Encoding := 'UTF-8';
xmlDocument.xml.LoadFromStream(aStream);
XMLDocument.active := true;
//...
string = oNode.GetAttributeNS('Text','');
但是我在字符串中得到é。
xml文件是:
<?xml version="1.0" encoding="UTF-8"?>
<ScreenProperties Dspf="SCR0133" DspfLib="CONV1" Width="800" Height="600" Marge="20">
<Formats>
<Format Name="FSFL">
<PopupSfl Column="OPTION1">
<Items>
<Item Value="1" Text="é" Multi="0"/>
<Item Value="2" Text="supprimer" Multi="0"/>
<Item Value="3" Text="toto" Multi="0"/>
</Items>
</PopupSfl>
<SflDoubleClick Column="OPTION1" Value="1"/>
<SflColors SwitchColors="true" OddColors="16777215" EvenColors="14024703"/>
<Fields>
<Field Name="IDBOOK" Conversion="0" Sort="1"/>
</Fields>
</Format>
<Format Name="FCTLSFL" OnCloseCommandKey="CACF03">
<Fields>
<Field Name="WDPOS" Conversion="0" Sort="1"/>
</Fields>
</Format>
<Format Name="EMPTY">
<Fields/>
</Format>
<Format Name="FOOTER">
<Fields/>
</Format>
</Formats>
</ScreenProperties>
如何获取正确的值?
我知道了,我没有将流保存到使用utf8编码的文件中...