Skip to content
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);
if (isFunction(this._config.beforeFirstChunk)) {
var modifiedChunk = this._config.beforeFirstChunk(chunk);
if (modifiedChunk !== undefined)
chunk = modifiedChunk;
}
}
this.isFirstChunk = false;
this._halted = false;
Expand Down