Skip to content

fix(csv-parse): encoding detection with bom#350

Merged
wdavidw merged 1 commit intoadaltas:masterfrom
nugit:bugfix/encoding-detection
Jul 1, 2022
Merged

fix(csv-parse): encoding detection with bom#350
wdavidw merged 1 commit intoadaltas:masterfrom
nugit:bugfix/encoding-detection

Conversation

@moroine
Copy link
Contributor

@moroine moroine commented Jun 30, 2022

This fixes adaltas/node-csv-parse#318

Describe the bug

Following test is failing:

import csvParse from 'csv-parse/lib/sync';

test('This is not working', () => {
      const data = Buffer.from('\uFEFFa,b,c\n"a","b","c"', 'utf16le');
      const records = csvParse(data, {
        bom: true,
      });
      expect(records).toEqual([
        ['a', 'b', 'c'],
        ['a', 'b', 'c'], // Got ["愀", "戀", "挀"]
      ]);
});

After some research, I found that while the options are re-evaluated upon encoding change, we still use old values for comment, escape & quote values.

@wdavidw wdavidw merged commit fd75e66 into adaltas:master Jul 1, 2022
@moroine moroine deleted the bugfix/encoding-detection branch July 1, 2022 07:23
@wdavidw
Copy link
Member

wdavidw commented Jul 1, 2022

Sounds good, thank you. It is now merged and published:

  • csv-parse: 5.2.1 => 5.2.2
  • csv: 6.1.4 => 6.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UTF 16 encoding detection is not working with quotes values

2 participants