In FileHelpers/FileHelpers/Fields/DelimitedField.cs
// Add Quotes If:
// - optional == false
// - is optional and contains the separator
// - is optional and contains a new line
if ((QuoteChar != '\0') &&
(QuoteMode == QuoteMode.AlwaysQuoted ||
QuoteMode == QuoteMode.OptionalForRead ||
((QuoteMode == QuoteMode.OptionalForWrite || QuoteMode == QuoteMode.OptionalForBoth)
&& mCompare.IndexOf(field, Separator, CompareOptions.Ordinal) >= 0) || hasNewLine))
StringHelper.CreateQuotedString(sb, field, QuoteChar);
else
sb.Append(field);
should be changed to
// Add Quotes If:
// - optional == false
// - is optional and contains the separator
// - is optional and contains the quote character
// - is optional and contains a new line
if ((QuoteChar != '\0') &&
(QuoteMode == QuoteMode.AlwaysQuoted ||
QuoteMode == QuoteMode.OptionalForRead ||
((QuoteMode == QuoteMode.OptionalForWrite || QuoteMode == QuoteMode.OptionalForBoth) &&
(mCompare.IndexOf(field, Separator, CompareOptions.Ordinal) >= 0 ||
mCompare.IndexOf(field, QuoteChar, CompareOptions.Ordinal) >= 0)) ||
hasNewLine))
StringHelper.CreateQuotedString(sb, field, QuoteChar);
else
sb.Append(field);
according to RFC 4180:
Each field may or may not be enclosed in double quotes (however some programs, such as Microsoft Excel, do not use double quotes at all). If fields are not enclosed with double quotes, then double quotes may not appear inside the fields.
If the user inputs a sole double quote:
1.1,",,",13772/8681,100,100,1,0,,,,,100,100
In that case two fields are omitted by the reading application. My workaround is to strip sole double quotes because in my case I don't need them. I just wanted to add this here since I stumbled on it today.
In FileHelpers/FileHelpers/Fields/DelimitedField.cs
should be changed to
according to RFC 4180:
If the user inputs a sole double quote:
1.1,",,",13772/8681,100,100,1,0,,,,,100,100In that case two fields are omitted by the reading application. My workaround is to strip sole double quotes because in my case I don't need them. I just wanted to add this here since I stumbled on it today.