davedelong/CHCSVParser

Parsed Data Replaces Double Quotes with Two Sets of Double Quotes

JamieEdge opened this issue · 1 comments

I have been using this library successfully for a while, but I have noticed that in the parsed array that is returned after reading a CSV, any double quotes have been returned as two double quotes.

For example, in a field there might be a value:

This is an example of "quoted text"

I expected that the parsed data I would get would be exactly the same, but instead I get the following:

This is an example of ""quoted text""

I found where this is done (on lines 645 to 648), but I wanted to ask why this is done? I am happy to submit a pull request to remove it if this isn't expected behaviour, but I just wanted to check first.

This is part of the CSV spec (2.7):

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. For example:

  "aaa","b""bb","ccc"