Add newlines to list of special CSV chars for quoting.
This commit is contained in:
parent
44b19ed36c
commit
045e3a5c95
|
|
@ -30,7 +30,9 @@ struct CsvStreamWriter(S) if (isByteOutputStream!S) {
|
|||
import std.regex : replaceAll, regex;
|
||||
import std.string : indexOf;
|
||||
string s = value.to!string();
|
||||
bool shouldValueBeQuoted = indexOf(s, '"') != -1 || indexOf(s, ',') != -1;
|
||||
bool shouldValueBeQuoted = indexOf(s, '"') != -1 ||
|
||||
indexOf(s, ',') != -1 ||
|
||||
indexOf(s, '\n') != -1;
|
||||
s = replaceAll(value.to!string(), regex("\""), "\"\"");
|
||||
if (shouldValueBeQuoted) {
|
||||
s = "\"" ~ s ~ "\"";
|
||||
|
|
|
|||
Loading…
Reference in New Issue