Closed zhu659zhu closed 5 months ago
ECMAScript operates in UCS2, therefore the supplied string is converted from UTF-8 to UCS which in your case represents a single code unit. An equivalent JS code:
const b = new Uint8Array([206, 176]);
console.log(new TextDecoder('utf-8').decode(b).length);
which prints 1.
When the input contains special characters, the value of the input JS function does not meet the expectations.
example:
the output is 1
i think 2 is as expected.