#1 2025-03-19 21:19:48

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 461

Torm.GetJsonValues has problem with greek characters

Today I update the mormot source for a project and I noticed that there is a character issue starting probably with commit 8338979 or one in the following 4-5 commits.

With the last changes I am getting the greek characters in form like Αιτιολόγιση για μη

The problem I noticed first has to do with Torm.GetJsonValues. Check the following source:
  TOrmSoup=class(Torm)
  private
    Fplanttwo: rawutf8;
    Fplantone: rawutf8;
    published
      property plantone:rawutf8 read Fplantone write Fplantone;
      property planttwo:rawutf8 read Fplanttwo write Fplanttwo;
  end;

procedure TForm3.Button1Click(Sender: TObject);
var o:tormsoup; s:rawutf8;
begin
o:=tormsoup.Create;
o.plantone:='Κρεμμύδι';
o.planttwo:='πατάτα';
s:=o.GetJsonValues(true,true,ALL_FIELDS);
end;

The result in s is now:
s='{"RowID":0,"plantone":"Ξ'#$9A'Ο'#$81'ΞµΞΌΞΌΟ'#$8D'δι","planttwo":"πατάτα"}'

Using JsontoObject instead of GetJsonValues does not produce this problem.

The reason I am using GetJsonValues (and not JsontoObject) is to have the possibility to select which fields I need to be exported to Json string.

Offline

#2 2025-03-20 07:59:39

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 461

Re: Torm.GetJsonValues has problem with greek characters

I noticed that EnsureRawUtf8 fixes it. I will use it, not to cause trouble.

Offline

#3 2025-03-20 08:17:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,007
Website

Re: Torm.GetJsonValues has problem with greek characters

There was a code page issue on Delphi Unicode (only).

Please try with
https://github.com/synopse/mORMot2/commit/be77a417b

I have added explicit regression tests to fight against this issue in the future:
https://github.com/synopse/mORMot2/commit/8d60177d5

Offline

#4 2025-03-20 08:36:33

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 461

Re: Torm.GetJsonValues has problem with greek characters

Many many thanks @ab

Offline

Board footer

Powered by FluxBB