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 1 commit
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
17 changes: 8 additions & 9 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 @@ -513,6 +511,7 @@ License: MIT
// First chunk pre-processing
if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
{
chunk = stripBom(chunk);
spearmootz marked this conversation as resolved.
Show resolved Hide resolved
var modifiedChunk = this._config.beforeFirstChunk(chunk);
if (modifiedChunk !== undefined)
chunk = modifiedChunk;
Expand Down