I'd say we follow RFC4180:
http://tools.ietf.org/html/rfc4180At least it is some kind of standard and you can build applications that interoperate based on that.
CSV data IMO means that only Delimiter (unless in a quoted field) should be taken a field separator. So the spaces would have to be part of the data, although they do not comply with rfc 4180.
Well, not following RFC4180 means we're defining yet another standard. Not a good idea, I think.
However, see section 2 point 4: "Spaces are considered part of a field and should not be ignored." So, this *does* comply with RFC4180.
Root cause of this problem was/is faulty implementation of TStrings.GetdelimitedText and TStrings.SetdelimitedText, see issue 19610 in the bugtracker.
Note: DelimitedText deals with *SDF* format, which is very similar to but not necessarily the same as RFC4180.
However, afer implementing the patch in 19610 (which aligns DelimitedText behaviour with Delphi), if we modify the output of DelimitedText to always quote fields that have spaces or quotes or line endings (CR and/or LF), we still maintain Delphi compatibility (see tests in bug report) and we end up outputting both valid SDF and CSV (if you set CommaText to true).
(So yes, I totally agree with your last post in that issue suggesting we quote stuff.)
On the import side, the SDF behaviour of not stripping trailing and leading spaces actually seems to match RFC4180.
After 19610 is implemented, we could take a look at whether reading csv data using delimitedtext works using a test program (which can be submitted to the compiler test program suite). I suspect it won't completely work... and fix that if necessary.
Then we could patch the stringgrid loadfromcsvfile and the save routine, as well as any other csv import/export routine floating around in FPC and Lazarus that we can lay our hands on.
*Edited for clarity