Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextDecoder.decode() ignores byteLength and byteOffset of TypedArray #856

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

duonglaiquang
Copy link
Contributor

This PR does the following

  • Fix an issue where TextDecoder.decode() decodes the entire backing buffer of TypedArray instead of the view's range.

Test cases

let encoder = new TextEncoder();
let arrayBuffer = encoder.encode('Hello, World!').buffer;

let decoder = new TextDecoder();
console.log(decoder.decode(arrayBuffer)); // Hello, World!
{
  let typedArray = new Uint8Array(arrayBuffer, 7);
  console.log(decoder.decode(typedArray)); // expected: "World!", got: "Hello, World!"
}
{
  let typedArray = new Uint8Array(arrayBuffer, 0, 5);
  console.log(decoder.decode(typedArray)); // expected: "Hello", got: "Hello, World!"
}

@rbri
Copy link
Member

rbri commented Aug 27, 2024

Thanks a lot, currently not in front of my pc, will have a look later today.

@rbri rbri merged commit be01b52 into HtmlUnit:master Aug 28, 2024
7 checks passed
@rbri
Copy link
Member

rbri commented Aug 28, 2024

will provide a new snapshot build

@rbri
Copy link
Member

rbri commented Aug 29, 2024

deployed....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants