Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior when setting CsvWriter.NewLine to something other than new line #16

Open
ChaosBladeCoder opened this issue Sep 25, 2016 · 1 comment

Comments

@ChaosBladeCoder
Copy link

There are some unexpected behaviors when setting CsvWriter.NewLine to something "crazy".

While this value is (obviously) meant to be either \r\n or \n to support different OS new line conventions, since it is a string, it can be set to any value, for example, || (two pipes). Many tools also support both reading and writing such a file (like SQL Server bcp.exe or SSIS; Excel however seems not to).

When I set CsvWriter.NewLine to be double pipes, two unexpected things happened:

  • String values that contain double pipes are NOT automatically surrounded by ValueDelimiter, even though this seems necessary in this situation,
  • String values that contain new lines ARE still automatically surrounded by ValueDelimiter, even though this does NOT seem necessary in this situation.

It seems like the grammar rules from rfc4180 have been generalised from "comma" and "double quote" to "any character" for the ValueSeparator and ValueDelimiter, but not for NewLine (which could be thought of as "Row delimiter").

@kentcb
Copy link
Owner

kentcb commented Oct 9, 2016

Hmm, the problem is that the parser itself assumes CR, LF, or CRLF line breaks. The RFC only allows for CRLF.

I think adding support for any newline string would be non-trivial and possibly not worth the effort. Leaving it open for now so I can think about it more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants