From a2c402c7c970781abeb50d4e52a9d8f3313ea88f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 4 Apr 2025 00:12:25 -0700 Subject: [PATCH] Test UTF-16 BE decoding `utf-16be` is not supported by Node.js's decoder in the `fs` module, but it is supported by the web standard Encoding API. So this is a good test to demonstrate the difference between the two. --- test/core.test.js | 10 ++++++++++ test/data/utf-16be.csv | Bin 0 -> 64 bytes 2 files changed, 10 insertions(+) create mode 100644 test/data/utf-16be.csv diff --git a/test/core.test.js b/test/core.test.js index ae33844..23eea4f 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -158,6 +158,16 @@ suite('CSVReader', { concurrency: true }, () => { ['12', '34'] ] }, + { + name: 'parses UTF-16 BE CSV', + input: './data/utf-16be.csv', + options: { encoding: 'utf-16be' }, + output: [ + ['column1', 'column2'], + ['ab', 'cd'], + ['12', '34'] + ] + }, { name: 'parses single value (no commas or newlines) CSV', input: './data/single-value.csv', diff --git a/test/data/utf-16be.csv b/test/data/utf-16be.csv new file mode 100644 index 0000000000000000000000000000000000000000..1b9733062825e3a38595be49f7ede9f78e85c778 GIT binary patch literal 64 ycmezOpCOqcpCN~#lp&WPkHL^Z2Ze9Mz{|kJkjRh(7Eb~53>l1oJYxnE5Dx&qfC`!b literal 0 HcmV?d00001 -- 2.47.3