Rad Studio 10 Seattle - XMLTransformProvider - Encoding UTF-8

1

I have 2 applications developed in RAD XE2. One is the object of typing data that will be written to an XML file and the other one responsible for reading, validating and importing the generated XML into the Database.

I decided to test the Rad 10 Seatle and recompile the applications. Almost everything works, but at the time of importing the data the compiled version in Delphi-10 does not recognize encoding (UTF-8). If I export to the Delphi-10 version and import it by the compiled version in XE2 it works normally.

For importing and generating the XML file I used the XML Mapper to create a configuration file (xtr). When I try to import the XML data into the XML Mapper, it displays the characters correctly (ã, ç, etc). For data import I use an XMLTransformProvider ("connected" to the xtr configuration file), and the XMLTransformProvider is "bound" to a clientdataset where the data is loaded. I think it is at this point that the problem occurs because when I view the data from the clientdataset, they appear incorrect (special carats are not recognized).

If anyone can give a tip, I'm grateful.

    
asked by anonymous 24.05.2016 / 16:32

1 answer

1

Try this alternative:

Create a private event named OnGetText as below, and in the AfterDate event of ClientDataSet, assign the routine below.

Procedure TForm1.OnGetText(Sender: TField; var Text: String; DisplayText: Boolean);
Begin
    text:=Utf8ToString(sender.asString);
End;

procedure TForm1.ClientDataSet1AfterOpen(DataSet: TDataSet);
var
    i:integer;
    f:TField;
begin
    for i:=0 to dataset.fields.count-1 do
    begin
        f:=dataset.fields[i];
        f.ongettext:= Self.OnGetText;
    end;
end;
    
26.06.2016 / 21:38