Skip to content

Commit

Permalink
Allow for escaping the delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
leaty committed May 28, 2021
1 parent 40ea4c4 commit 96b2a5b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions csv-core/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,9 @@ impl Reader {
EndFieldDelim => (StartField, NfaInputAction::Epsilon),
EndFieldTerm => (InRecordTerm, NfaInputAction::Epsilon),
InField => {
if self.delimiter == c {
if self.escape == Some(c) {
(InQuotedField, NfaInputAction::Discard)
} else if self.delimiter == c {
(EndFieldDelim, NfaInputAction::Discard)
} else if self.term.equals(c) {
(EndFieldTerm, NfaInputAction::Epsilon)
Expand All @@ -1023,7 +1025,9 @@ impl Reader {
}
}
InQuotedField => {
if self.quoting && self.quote == c {
if self.delimiter == c {
(InField, NfaInputAction::CopyToOutput)
} else if self.quoting && self.quote == c {
(InDoubleEscapedQuote, NfaInputAction::Discard)
} else if self.quoting && self.escape == Some(c) {
(InEscapedQuote, NfaInputAction::Discard)
Expand Down

0 comments on commit 96b2a5b

Please sign in to comment.