TextDecoder.decode
does not respect the "ascii" label parameter passed to the constructor according to my understanding of it. The example below provides the same values on Chromium and Node 18.17.1. Can someone explain why the TextDecoder is providing a different value than the fromCharCode function?
Code
const array = new Uint8Array([173, 148, 130, 203, 88]);
console.log(array);
const decoder = new TextDecoder("ascii");
const value = decoder.decode(array);
console.log(`Length: ${value.length}`)
console.log("Uint8|fromCharCode|TextDecoder")
for (i in value){
console.log(`${array[i]}|${String.fromCharCode(array[i]).charCodeAt(0)}|${value.charCodeAt(i)}`);
console.log(String.fromCharCode(array[i]))
}
Output
Uint8|fromCharCode|TextDecoder
173|173|173
148|148|8221
130|130|8218
203|203|203
88|88|88