2025-03-18 15:28:35 -03:00
|
|
|
<!DOCTYPE html>
|
2023-05-30 03:18:23 -03:00
|
|
|
<script src="../include.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
test(() => {
|
|
|
|
|
try {
|
|
|
|
|
let decoder = new TextDecoder("utf-8");
|
|
|
|
|
println(`[${decoder.decode(new Uint8Array([0x41, 0x42, 0x43]))}]`); // "ABC"
|
|
|
|
|
println(`[${decoder.decode()}]`);
|
2025-07-05 13:00:04 -03:00
|
|
|
|
|
|
|
|
const surrogate = decoder.decode(new Uint8Array([0xed, 0xa0, 0x80])); // U+D800
|
|
|
|
|
println(`[${surrogate.codePointAt(0).toString(16)}]`);
|
2026-05-17 20:47:40 -03:00
|
|
|
|
|
|
|
|
const truncatedTail = decoder.decode(new Uint8Array([0xf0, 0x9f, 0x98]));
|
|
|
|
|
println(`[${truncatedTail.length}, ${truncatedTail.codePointAt(0).toString(16)}]`);
|
2025-07-05 13:00:04 -03:00
|
|
|
} catch (e) {
|
2023-05-30 03:18:23 -03:00
|
|
|
println("ERROR: " + e.name + ": " + e.message);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|