Skip to content

error for "Windows-1252" encoding for char "\u2013" #59515

@Neilpang

Description

@Neilpang

Version

24.6.0,

Platform

Windows and Ubuntu 
x86-64

Subsystem

No response

What steps will reproduce the bug?

Here is the testing code:

  function decodeWindows1252(buffer) {
    const decoder = new TextDecoder('windows-1252');
    return decoder.decode(buffer);
  }

  console.log("icu version: " + process.versions.icu);
  let b = new Uint8Array(1)
  b[0] = 150; // 150 in windows-1252 is unicode 2013
  let u = decodeWindows1252(b);
  console.log("Decoded Windows-1252:", u);
  console.log("Encoded Windows-1252:", u.charCodeAt(0).toString(16));

Here is the correct output in nodejs v22.12.0

icu version: 76.1
Decoded Windows-1252: –
Encoded Windows-1252: 2013

Here is the wrong output for nodejs v24.6.0:

icu version: 77.1
Decoded Windows-1252:
Encoded Windows-1252: 96

I tested all the v20, v22 and v23 and v24 versions, some of them are correct, while ther others are wrong.

v20.0.0 - v20.18.2 : correct
v20.18.3 - v20.19.4 : wrong

v22.0.0 - v22.12.0 : correct
v22.13.0 - v22.18.0 : wrong

v23.0.0 - v23.13.0 : correct
v23.4.0 - v23.11.1 : wrong

v24.0.0 - v24.6.0 : wrong

How often does it reproduce? Is there a required condition?

100% reproduce.

What is the expected behavior? Why is that the expected behavior?

the correct above.

What do you see instead?

NA

Additional information

No response

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