Skip to content

String arrives with different characters in Firefox #4

@mk-pmb

Description

@mk-pmb

I wrote a node.js program to generate HTML code, the core:

console.log(['\uFEFF<!DOCTYPE html><html><body><p></p><script>',
  String(charCodes),
  'console.log(charCodes(' + jsStringify(animals) + '));',
  'console.log(' + charCodes(jsStringify(animals)) + ');',
  '</script></body></html>'].join('\n'));

I gisted the full source, also the generated HTML and what Firefox prints in its console when loading the HTML:

{ "dog": "[d83d][dc15]", "cow": "[d83d][dc04]", "halfbreed": "[fffd][fffd]" }
{ "dog": "[d83d][dc15]", "cow": "[d83d][dc04]", "halfbreed": "[dc15][d83d]" }

As you can see, in the first expression, the halfbreed characters both became U+FFFD. Probably some Unicode interpolation is messing with JavaScript's UCS-2 characters. Is this a bug? If a feature instead, it should be documented more prominently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions