mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-14 15:13:07 +00:00
33 lines
1.1 KiB
HTML
33 lines
1.1 KiB
HTML
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
let testCounter = 1;
|
|
function testPart(part) {
|
|
println(`${testCounter++}. ${JSON.stringify(part())}`);
|
|
}
|
|
|
|
// 1. TextEncoder encode
|
|
testPart(() => new TextEncoder().encode('Well Hello Friends 😀!'));
|
|
|
|
// 2. TextEncoder encodeInto
|
|
testPart(() => {
|
|
const buffer = new Uint8Array(32);
|
|
new TextEncoder().encodeInto('Well Hello Friends 😀!', buffer);
|
|
return buffer
|
|
});
|
|
|
|
// 3. TextEncoder encodeInto result read
|
|
testPart(() => {
|
|
const buffer = new Uint8Array(32);
|
|
const result = new TextEncoder().encodeInto('Well Hello Friends 😀!', buffer);
|
|
return result.read;
|
|
});
|
|
|
|
// 3. TextEncoder encodeInto result written
|
|
testPart(() => {
|
|
const buffer = new Uint8Array(32);
|
|
const result = new TextEncoder().encodeInto('Well Hello Friends 😀!', buffer);
|
|
return result.written;
|
|
});
|
|
});
|
|
</script>
|