DELPHI XE - ClientDataSet problem with Unicode chars in XML file
Posted on 2011-09-09
I have an simple XML file with 2 fields - Name and Value. I am looking to use this XML file like a database table i.e. locate values based on name, and update values based on name as well. I have code that does all of this using a TClientDataSet, and XMLTransFormProvider, the two .xtr files defining the 'ToDataPacket' and 'ToXML' transformations. I also have a TDataSource tied to a DB Grid to display the records. Everything works fine until I hit a name/value record in which the value field contains unicode characters. In this case, the TDataSet returns the single byte representation '??????' rather than the actual unicode chars. Strangely enough, when I WRITE to the file replacing a value with a unicode string, it correctly goes into the xml file, but still will not be 'read' out and be displayed correctly.
The xml file is a Unicode file with a little endian BOM and displays correctly in IE. I have tried both including and not including 'encoding="UTF-16" in the header. The clientdataset has the fields defined as ftWideString. The xtr files also have defined the fields as 'string.uni' both in the DataPacket and XML xtr files.
What am I missing? There is probably a simple answer to this, but you know how things are after staring at something for a while...!