Skip to content
File

Blob: src/workerd/api/tests/textdecoder-utf16-odd-offset-test.js

javascript19 lines
1// Copyright (c) 2026 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4import { strictEqual } from 'node:assert';
5 
6export const TextDecoderUtf16OddOffset = {
7 async test() {
8 const decoder = new TextDecoder('utf-16le');
9 const buffer = new ArrayBuffer(200);
10 const view = new Uint8Array(buffer, 3, 20);
11 for (let i = 0; i < 20; i += 2) {
12 view[i] = 0x42;
13 view[i + 1] = 0x00;
14 }
15 const result = decoder.decode(view);
16 strictEqual(result, 'BBBBBBBBBB');
17 },
18};