[fpc-devel] Is the code in wiki correct?
Michael Van Canneyt
michael at freepascal.org
Sat May 9 08:53:59 CEST 2020
On Fri, 8 May 2020, Amir wrote:
> Hi there,
> I was looking for a native implementation for JoinStrings and ended up in
> In Conversion to and from delimited strings
> section, it claims the following code works if the separator is a string:
> MyStringList:= TStringList.create;
> MyStringList.SkipLastLineBreak := True;
> result := StringReplace(MyStringList.Text,Lineending,'\n', [rfReplaceAll,
> I believe this is not correct. What if there is a newline(LineEnding) in one
> of the strings?
It will also be replaced. So yes, the code is wrong for such a case.
TStringlist is not a silver bullet, and it is definitely not a replacement
for CSV-kind of functionality. If someone needs CSV, (s)he should use the TCSVDocument class.
More information about the fpc-devel