Skip to content

Commit

Permalink
fix for whitespaced quoted separators
Browse files Browse the repository at this point in the history
  • Loading branch information
dejan1024 committed Jan 7, 2024
1 parent f032c52 commit 3c2afd5
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 3c2afd5

Please sign in to comment.