You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{description: "Other quote char but without setting escape char (should be 2x the quote char)",input: [['a','x+y']],config: {quoteChar: "+"},expected: 'a,+x++y+'}
While looking into #1035 I noticed that the
escapeChar
is wrongly set when thequoteChar
is changed. This is only the case forPapap.unparse
.Example:
which gives currently
As you can see, the
escapeChar
is still set to""
and not++
.The issue was introduced in this commit: a627547#diff-fbb8d0b19dc4586fadd80f52a7b49415d2d41a5fdccaeaa728f7fca51cfbbb29R277
This can be easily be fixed when changing line https://github.com/mholt/PapaParse/blob/4af6882e0ea91b0baad30345f190b38d50e7535e/papaparse.js#L364C4-L364C29
into
And here is a test-case for the
UNPARSE_TESTS
However, fixing this will result in
The correct result would be
The other part of the issue is that in line
PapaParse/papaparse.js
Line 472 in 4af6882
Will always set
needsQuotes=true
if the field contains a"
becausePapa.BAD_DELIMITERS
is defined as['\r', '\n', '"', Papa.BYTE_ORDER_MARK]
.There are different ways to fix this, here is one
Papa.NEED_QUOTES_CHARS=['\r', '\n']
and use it here instead ofPapa.BAD_DELIMITERS
str.indexOf(_quoteChar) > -1
These changed will also fix issue #1035
At this point, a PR would probably be easier... However, this can be implemented in different ways, so I'm hesitant.
The text was updated successfully, but these errors were encountered: