v5
- by demonthos 11/3/202200
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
let utf8decoder = new TextDecoder();
let u8arr = new Uint8Array([0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64]);
function utf8Decode(start, _end) {
    let pos = start;
    const end = _end;
    let out = "";
    while (pos < end) {
        const byte1 = u8arr[pos++];
        if ((byte1 & 0x80) === 0) {
        // 1 byte
        out += String.fromCharCode(byte1);
        } else if ((byte1 & 0xe0) === 0xc0) {
        // 2 bytes
        const byte2 = u8arr[pos++] & 0x3f;
        out += String.fromCharCode(((byte1 & 0x1f) << 6) | byte2);
        } else if ((byte1 & 0xf0) === 0xe0) {
        // 3 bytes
        const byte2 = u8arr[pos++] & 0x3f;
        const byte3 = u8arr[pos++] & 0x3f;
        out += String.fromCharCode(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3);
        } else if ((byte1 & 0xf8) === 0xf0) {
        // 4 bytes
        const byte2 = u8arr[pos++] & 0x3f;
        const byte3 = u8arr[pos++] & 0x3f;
        const byte4 = u8arr[pos++] & 0x3f;
        let unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
        if (unit > 0xffff) {
            unit -= 0x10000;
            out += String.fromCharCode(((unit >>> 10) & 0x3ff) | 0xd800);
            unit = 0xdc00 | (unit & 0x3ff);
        }
        out += String.fromCharCode(unit);
        } else {
        out += String.fromCharCode(byte1);
        }
    }

    return out;
}
function asciiDecode(start, _end) {
    let pos = start;
    const end = _end;
    let out = "";
    while (pos < end) {
      out += String.fromCharCode(u8arr[pos++]);
    }
    return out;
  }
delete caserun single casemove downdrag and drop case


ready



let all_text = utf8decoder.decode(u8arr);
all_text.substr(0,3);
all_text.substr(3,u8arr.length-1);

delete caserun single casemove upmove downdrag and drop case


ready



utf8Decode(0, 3);
utf8Decode(3, u8arr.length-1);

delete caserun single casemove upmove downdrag and drop case


ready



asciiDecode(0, 3);
asciiDecode(3, u8arr.length-1);

delete caserun single casemove updrag and drop case


ready



utf8decoder.decode(new Uint8Array(u8arr.buffer, 0, 3));
utf8decoder.decode(new Uint8Array(u8arr.buffer, 3));

Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN