You are not logged in.
Pages: 1
I noticed different behavior when saving a dynamic array of strings and a dynamic array of records. Should it be? I use pre-unicode version Delphi - BDS2006. When I compiled in Delphi XE4, it's all values the same
Here is the code.
program pStrangeSave;
{$APPTYPE CONSOLE}
uses
SysUtils,SynCommons,mORMot;
type
TListKanalov = array of string;
const
__Rec = 'name string';
type
TRec = packed record
name:string;
end;
TListRecKanalov = array of TRec;
var
Kanals : TListKanalov; RecKanals : TListRecKanalov;
da,daRec:TDynArray; i:Integer; s: RawUTF8;
const
ArrStr : array [0..2] of string = ('фаза1','фаза2','фаза3');//cirillic name
begin
TJSONSerializer.RegisterCustomJSONSerializerFromText(TypeInfo(TRec),__Rec);
SetLength(Kanals,3);
for i := 0 to 2 do
Kanals[i]:=ArrStr[i];
da.Init(TypeInfo(TListKanalov),Kanals);
SetLength(RecKanals,3);
for i := 0 to 2 do
RecKanals[i].name:=ArrStr[i];
daRec.Init(TypeInfo(TListRecKanalov),RecKanals);
with TTextWriter.CreateOwnedStream() do begin
AddDynArrayJSON(da); AddCR; AddDynArrayJSON(daRec); SetText(s);
end;
FileFromString(s,'strange.txt');
end.
Offline
Pages: 1