Skip to content

Commit 96b2a5b

Browse files
committed
Allow for escaping the delimiter
1 parent 40ea4c4 commit 96b2a5b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

csv-core/src/reader.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,9 @@ impl Reader {
10141014
EndFieldDelim => (StartField, NfaInputAction::Epsilon),
10151015
EndFieldTerm => (InRecordTerm, NfaInputAction::Epsilon),
10161016
InField => {
1017-
if self.delimiter == c {
1017+
if self.escape == Some(c) {
1018+
(InQuotedField, NfaInputAction::Discard)
1019+
} else if self.delimiter == c {
10181020
(EndFieldDelim, NfaInputAction::Discard)
10191021
} else if self.term.equals(c) {
10201022
(EndFieldTerm, NfaInputAction::Epsilon)
@@ -1023,7 +1025,9 @@ impl Reader {
10231025
}
10241026
}
10251027
InQuotedField => {
1026-
if self.quoting && self.quote == c {
1028+
if self.delimiter == c {
1029+
(InField, NfaInputAction::CopyToOutput)
1030+
} else if self.quoting && self.quote == c {
10271031
(InDoubleEscapedQuote, NfaInputAction::Discard)
10281032
} else if self.quoting && self.escape == Some(c) {
10291033
(InEscapedQuote, NfaInputAction::Discard)

0 commit comments

Comments
 (0)