Skip to content

Encoding decoder tests don't test codepoints #56748

@ChALkeR

Description

@ChALkeR

E.g. new TextDecoder('shift-jis').decode(Uint8Array.of(0x5C)) is \, not ¥ per spec and in all major browsers.
But test data has <span data-cp="A5" data-bytes="5C">

The mismatch is also noticeable in the test runner, on the very second row -- symbols are different + assert shows not a ¥ sign:

Image

Also e.g. new TextDecoder('iso-2022-jp').decode(Uint8Array.of(0x1B, 0x24, 0x42, 0x21, 0x5D, 0x1B, 0x28, 0x42)).codePointAt().toString(16) is ff0d and not 2212 as in tests:

<span data-cp="2212" data-bytes="1B 24 42 21 5D 1B 28 42">�$B!]�(B</span>

Those don't cause failures because the test runner doesn't test bytes -> charcode decoding.
What it tests here is that html decoding of bytes matches decoder decoding of the same bytes, but nothing compares them to the codepoint in the test data:

assert_equals(
nodes[i].textContent,
decoder(nodes[i].dataset.bytes)
);

(cc @domenic?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions