From: Ardis Lu Date: Fri, 4 Apr 2025 07:12:25 +0000 (-0700) Subject: Test UTF-16 BE decoding X-Git-Tag: v0.1.0~31 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=a2c402c7c970781abeb50d4e52a9d8f3313ea88f;p=csvio 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. --- 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 0000000..1b97330 Binary files /dev/null and b/test/data/utf-16be.csv differ