#1 2017-12-15 10:00:12

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

RawUTF8ArrayToCSV & CSVToRawUTF8DynArray

Hi,

I converted this rawutf8  dyn array :

['A'
'B'
''
'C'
''] 

to csv with RawUTF8ArrayToCSV, obtaining  A,B,,C,  as result.

When I call CSVToRawUtf8DynArray , then returned array ignores the blanks element of the array and returns

['A'
'B'
'C']


I have modified the function in Syncommons , excluding the control on s>''. Now it seems to work well, returning the original array;


procedure CSVToRawUTF8DynArray(CSV: PUTF8Char; var Result: TRawUTF8DynArray;
  Sep: AnsiChar; TrimItems: boolean);
var s: RawUTF8;
begin
  while CSV<>nil do begin
    s := GetNextItem(CSV,Sep);
    if TrimItems then
      s := trim(s);
    //if s<>'' then begin
      SetLength(Result,length(Result)+1);
      Result[high(Result)] := s;
    //end;
  end;
end;

Offline

#2 2017-12-15 11:16:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: RawUTF8ArrayToCSV & CSVToRawUTF8DynArray

But you broke the existing functionality... so will break existing code on production, which may expect this behavior.

Please check https://synopse.info/fossil/info/2757734c95

Offline

#3 2017-12-15 11:35:22

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

Re: RawUTF8ArrayToCSV & CSVToRawUTF8DynArray

Ok,

I've modified as you suggested.

Tx very much

Offline

Board footer

Powered by FluxBB