Skip to content

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

Description

@ChaosBladeCoder

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").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions