diff --git a/docs/docs.html b/docs/docs.html
index 8777802..df87a72 100644
--- a/docs/docs.html
+++ b/docs/docs.html
@@ -258,6 +258,7 @@
{
quotes: false, //or array of booleans
quoteChar: '"',
+ escapeChar: '"',
delimiter: ",",
header: true,
newline: "\r\n",
@@ -293,6 +294,12 @@
The character used to quote fields.
+
delimiter
diff --git a/papaparse.js b/papaparse.js
index 5c7b5ed..70c4edc 100755
--- a/papaparse.js
+++ b/papaparse.js
@@ -273,6 +273,9 @@ License: MIT
/** quote character */
var _quoteChar = '"';
+ /** escaped quote character, either "" or " */
+ var _escapedQuote = _quoteChar + _quoteChar;
+
/** whether to skip empty lines */
var _skipEmptyLines = false;
@@ -353,6 +356,10 @@ License: MIT
_columns = _config.columns;
}
+
+ if (_config.escapeChar !== undefined) {
+ _escapedQuote = _config.escapeChar + _quoteChar;
+ }
}
@@ -439,7 +446,7 @@ License: MIT
if (str.constructor === Date)
return JSON.stringify(str).slice(1, 25);
- str = str.toString().replace(quoteCharRegex, _quoteChar + _quoteChar);
+ str = str.toString().replace(quoteCharRegex, _escapedQuote);
var needsQuotes = (typeof _quotes === 'boolean' && _quotes)
|| (Array.isArray(_quotes) && _quotes[col])
diff --git a/tests/test-cases.js b/tests/test-cases.js
index 5ea71e0..07b8a53 100644
--- a/tests/test-cases.js
+++ b/tests/test-cases.js
@@ -1739,6 +1739,18 @@ var UNPARSE_TESTS = [
input: [{a: 1, b: '2'}, {}, {a: 3, d: 'd', c: 4,}],
config: {columns: ['a', 'b', 'c']},
expected: 'a,b,c\r\n1,2,\r\n\r\n3,,4'
+ },
+ {
+ description: "Use different escapeChar",
+ input: [{a: 'foo', b: '"quoted"'}],
+ config: {header: false, escapeChar: '\\'},
+ expected: 'foo,"\\"quoted\\""'
+ },
+ {
+ description: "test defeault escapeChar",
+ input: [{a: 'foo', b: '"quoted"'}],
+ config: {header: false},
+ expected: 'foo,"""quoted"""'
}
];
|