Skip to content

TextDecoder defaults to stream: true instead of false with null optionsΒ #61411

@ChALkeR

Description

@ChALkeR
> new TextDecoder('utf-16le').decode(Uint8Array.of(0x80), null)
''

For any multi-byte encoding except utf-8 fast path

Should be:

> new TextDecoder('utf-16le').decode(Uint8Array.of(0x80), null)
'οΏ½'

This code here is wrong:

let flags = 0;
if (options !== null)
flags |= options.stream ? 0 : CONVERTER_FLAGS_FLUSH;

When options is null (instead of default empty object), flags is 0, but should be CONVERTER_FLAGS_FLUSH

Overall, the flags-based logic is too complex and convoluted

Will be fixed in #61409

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions