German Umlaute with Lazarus

try to check content of any widestring field like:

function tohex(aStr: WideString): Widestring;
var
  i: integer;
begin
  Result:='';
  for i := 1 to Length(aStr) do
    Result:=Result+ '$'+inttohex(ord(aStr[i]),4);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if test31144_utf8.Active then begin
    memo1.Lines.Add('=======');
    memo1.Lines.Add('WSTR hex = '+tohex(tbl_test31144_utf8.FieldByName('WStr').AsWideString));
  end;
end;

I have

that said that data in TDAMemDataTable is stored correctly, the same as in Delphi, but lazarus controls can’t show UTF16 chars (=widestring) correctly by some reasons


you can change this behavior and store data in TDAMemDataTable in UTF8 format via onReadFieldValue event of bin2 datastreamer.

procedure TForm1.InternalDataStreamerReadFieldValue(const aField: TDAField;
  var Value: Variant);
begin
  if VarIsStr(Value) then Value := VarToWideStr(Value);
end; 

in this case, it will be displayed correctly, except UTF8 encoded string takes a lot more space and it will probably not hold properly in dataset.
in given example, WSTR has widestring(20) field.

as you see, it cuts latest 2 chars:

it can be fixed via increasing field length.

AFAIK, UTF8 encoded data takes up to 6 chars for holding one UTF16 char , so storing 20 UTF16 in lazarus can take up to 120 utf8 chars.

note: you need to adjust every TDAMemDataTable in lazarus manually