davedelong/CHCSVParser — pull request #33 by macdrevx (2013-03-27 22:31:58+00:00)
Title: Add separate option for preserving or stripping leading and trailing whitespace

As of version 2.0.5, CHCSVParser's `CHCSVParserOptionsSanitizesFields` option also strips whitespace. I have a use case where I want only the unescaped content for escaped fields and also want leading and trailing whitespace to be preserved for unescaped fields. Currently this is not possible since stripping/preserving whitespace and unescaping escaped fields are both toggled by `CHCSVParserOptionsSanitizesFields`.

To address this issue, I have split whitespace stripping out into a separate option named `CHCSVParserOptionsStripsLeadingAndTrailingWhitespace`

`CHCSVParserOptionsSanitizesFields | CHCSVParserOptionsStripsLeadingAndTrailingWhitespace` gives results equivalent to the 2.0.5 behavior with one change:

a field like this: `, " foo " ,` would be parsed as `'foo'` under 2.0.5 with `CHCSVParserOptionsSanitizesFields`. With my changes, and the `CHCSVParserOptionsSanitizesFields | CHCSVParserOptionsStripsLeadingAndTrailingWhitespace` flags set, the leading and trailing whitespace _inside_ the escaped sequence will be preserved: `' foo '`