JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.69k stars 1.06k forks source link

Cannot use `\n` as delimiter #2274

Open Chewy5639 opened 1 month ago

Chewy5639 commented 1 month ago

Describe the bug Attempting to set CsvConfiguration.Delimiter to \n results in validation error:

The delimiter ' ' cannot be a line ending. ('\r', '\n', '\r\n')

To Reproduce

var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
    Delimiter = "\n",
    NewLine = "~" //Some non line ending character
};

_csvReader = new CsvReader(reader, config);

Expected behavior It appears that the CsvConfiguration.Validate method is checking against a hard coded array of line ending characters. The expected behaviour is to allow Delimiter to be \r, \n, or \r\n as long as NewLine is something different.