Rad Studio 10 Seattle - Xmltransformprovider - Encoding UTF-8

Asked

Viewed 585 times

1

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

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

To import and generate the XML file I used the XML Mapper to create a configuration file (xtr). When I test the import of XML data inside the XML Mapper, it displays the carcter correctly (ã, ç, etc). For data import I use an Xmltransformprovider ("connected" to the xtr configuration file) and the Xmltransformprovider is "connected" to a clientdataset where the data is loaded. I think it is at this point that the problem occurs, because when I visualize the data of the clientdataset, they appear incorrect (the special characters are not recognized).

If anyone can give a hint, I’d be grateful.

1 answer

1


Try this alternative:

Create a private event called Ongettext as below and in the Clientdataset Afteropen event 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;
  • Hello Carlos, Thanks for the help. The overlay of the Ongettext method did not work, but the conversion with Utf8tostring works. For now I’m using the code you put in the Afteropen to correct "in hand" after opening the table until I figure out how to overwrite Ongettext correctly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.