Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip BOM when streaming chunk #1026

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions papaparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ License: MIT
}



// Strip character from UTF-8 BOM encoded files that cause issue parsing the file
function stripBom(string) {
if (string.charCodeAt(0) === 0xfeff) {
return string.slice(1);
}
return string;
}

function CsvToJson(_input, _config)
{
Expand Down Expand Up @@ -249,14 +255,6 @@ License: MIT
streamer = new FileStreamer(_config);

return streamer.stream(_input);

// Strip character from UTF-8 BOM encoded files that cause issue parsing the file
function stripBom(string) {
if (string.charCodeAt(0) === 0xfeff) {
return string.slice(1);
}
return string;
}
}


Expand Down Expand Up @@ -511,11 +509,14 @@ License: MIT
this.parseChunk = function(chunk, isFakeChunk)
{
// First chunk pre-processing
if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
if (this.isFirstChunk)
{
var modifiedChunk = this._config.beforeFirstChunk(chunk);
if (modifiedChunk !== undefined)
chunk = modifiedChunk;
chunk = stripBom(chunk);
spearmootz marked this conversation as resolved.
Show resolved Hide resolved
if (isFunction(this._config.beforeFirstChunk)) {
var modifiedChunk = this._config.beforeFirstChunk(chunk);
if (modifiedChunk !== undefined)
chunk = modifiedChunk;
}
}
this.isFirstChunk = false;
this._halted = false;
Expand Down
Loading