sc-im icon indicating copy to clipboard operation
sc-im copied to clipboard

Support escaped double-quotes.

Open dotancohen opened this issue 3 years ago • 7 comments
trafficstars

From RFC-4180

If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote.

Therefore, a CSV file with the following content should be supported in SC-IM:

foo,above,bar
foo,My daughter said ""hello"" this morning.,bar
foo,below,bar

On opening a file with such text, SC-IM currently throws a "syntax error". Then after pressing Enter the file opens, but the cell with the escaped double-quote is truncated. The remaining cells display properly.

dotancohen avatar Dec 08 '21 13:12 dotancohen

Screenshot of SC-IM displaying a file with the text in the above comment: image

dotancohen avatar Dec 08 '21 13:12 dotancohen

Yes. I won't call this a bug.Sc-im is just not rfc4180 compliant.There was an old issue regarding this. Sc-im does not rely on a csv library that can handle this cases. (If you find any for C, please let me know).Nevertheless, please feel free to open a discussion so other can vote on this.. Let's call it enhancement.thanks

andmarti1424 avatar Dec 08 '21 13:12 andmarti1424

Andres,

I use https://github.com/rgamble/libcsv This one can handle such things.

rgds Roman

roman65536 avatar Dec 14 '21 15:12 roman65536

Thank you Roman. Will take a look at it

andmarti1424 avatar Dec 14 '21 15:12 andmarti1424

This problem is not specific to csv import: it seems sc-im cannot display cells with doublequotes in them and considers this a syntax error in the sc format.

For example, I get the same when I try to insert a cell with a doublequote in sc-im, and with other imports.

pjvm742 avatar Jan 05 '22 16:01 pjvm742

@pjvm742 could it be that this also happen on sc?

andmarti1424 avatar Feb 03 '22 15:02 andmarti1424

could it be that this also happen on sc?

In sc, when inserting a text value you have to give it in doublequotes, and an unescaped doublequote inside the value gives a similar error as in sc-im.

I did find out that you can escape doublequotes with a backslash, e.g. inserting "\"what?\"" works and displays as "what?". This also works in sc-im.

pjvm742 avatar Feb 03 '22 16:02 pjvm742