Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

UTF 16 encoding detection is not working with quotes values #318

@moroine

Description

@moroine

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 ["愀", "戀", "挀"]
      ]);
}

While this is working

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,
        encoding: 'utf16le',
      });
      expect(records).toEqual([
        ['a', 'b', 'c'],
        ['a', 'b', 'c'],
      ]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions