]> git.ardis.lu - csvio/commitdiff
Test UTF-16 BE decoding
authorArdis Lu <ardisglu@gmail.com>
Fri, 4 Apr 2025 07:12:25 +0000 (00:12 -0700)
committerArdis Lu <ardisglu@gmail.com>
Fri, 4 Apr 2025 07:12:25 +0000 (00:12 -0700)
`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
test/data/utf-16be.csv [new file with mode: 0644]

index ae338440323336672016e47af6082d1d245389ec..23eea4f08730dab64064a3fa25a7ff18aee1d8b4 100644 (file)
@@ -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 (file)
index 0000000..1b97330
Binary files /dev/null and b/test/data/utf-16be.csv differ
This page took 0.037715 seconds and 4 git commands to generate.