Skip to content

Text decoding should be specified for JS, JSON & text imports #117

@eemeli

Description

@eemeli

ECMA-262 does not define how to parse a file into a module, when it's imported into JS. For browsers, this is defined by the HTML standard, which includes this:

Let sourceText be the result of UTF-8 decoding bodyBytes.

That applies for all imports, be it for JS modules, JSON modules, or the upcoming text modules.

For text modules, the intent in its HTML standard changes is to match the behaviour of Fetch's .text(), which already now mandates using the UTF-8 decode algorithm for all files.

I'd be surprised if some runtime wasn't currently at least detecting a BOM and potentially parsing UTF-16 content as UTF-16 rather than UTF-8.

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