Skip to content

Commit

Permalink
Merge pull request #154 from dejan1024/trimquote
Browse files Browse the repository at this point in the history
fix for trimmed quoted separators
  • Loading branch information
d99kris authored Jan 27, 2024
2 parents f032c52 + 3c2afd5 commit 5336a4c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/rapidcsv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1584,10 +1584,19 @@ namespace rapidcsv
{
if (buffer[i] == mSeparatorParams.mQuoteChar)
{
if (cell.empty() || (cell[0] == mSeparatorParams.mQuoteChar))
if (cell.empty() || (cell[0] == mSeparatorParams.mQuoteChar))
{
quoted = !quoted;
}
else if(mSeparatorParams.mTrim)
{
// allow whitespace before first mQuoteChar
const auto firstQuote = std::find(cell.begin(), cell.end(), mSeparatorParams.mQuoteChar);
if(std::all_of(cell.begin(), firstQuote, [](int ch) { return isspace(ch); }))
{
quoted = !quoted;
}
}
cell += buffer[i];
}
else if (buffer[i] == mSeparatorParams.mSeparator)
Expand Down

0 comments on commit 5336a4c

Please sign in to comment.