|
1 | 1 | local ftcsv = {
|
2 |
| - _VERSION = 'ftcsv 1.1.3', |
| 2 | + _VERSION = 'ftcsv 1.1.4', |
3 | 3 | _DESCRIPTION = 'CSV library for Lua',
|
4 | 4 | _URL = 'https://github.com/FourierTransformer/ftcsv',
|
5 | 5 | _LICENSE = [[
|
@@ -215,7 +215,7 @@ local function parseString(inputString, inputLength, delimiter, i, headerField,
|
215 | 215 | -- end
|
216 | 216 |
|
217 | 217 | -- newline?!
|
218 |
| - elseif ((currentChar == CR and nextChar == LF) or currentChar == LF) then |
| 218 | + elseif (currentChar == CR or currentChar == LF) then |
219 | 219 | if fieldsToKeep == nil or fieldsToKeep[headerField[fieldNum]] then
|
220 | 220 | -- create the new field
|
221 | 221 | field = createField(inputString, quote, fieldStart, i, doubleQuoteEscape)
|
@@ -347,7 +347,13 @@ function ftcsv.parse(inputFile, delimiter, options)
|
347 | 347 | end
|
348 | 348 |
|
349 | 349 | -- parse through the headers!
|
350 |
| - local headerField, i = parseString(inputString, inputLength, delimiter, 1) |
| 350 | + local startLine = 1 |
| 351 | + |
| 352 | + -- check for BOM |
| 353 | + if string.byte(inputString, 1) == 239 and string.byte(inputString, 2) == 187 and string.byte(inputString, 3) == 191 then |
| 354 | + startLine = 4 |
| 355 | + end |
| 356 | + local headerField, i = parseString(inputString, inputLength, delimiter, startLine) |
351 | 357 | i = i + 1 -- start at the next char
|
352 | 358 |
|
353 | 359 | -- make sure a header isn't empty
|
|
0 commit comments