11cb0ef41Sopenharmony_ci<!doctype html> 21cb0ef41Sopenharmony_ci<script src=/resources/testharness.js></script> 31cb0ef41Sopenharmony_ci<script src=/resources/testharnessreport.js></script> 41cb0ef41Sopenharmony_ci<script src=resources/ranges.js></script> 51cb0ef41Sopenharmony_ci<script> 61cb0ef41Sopenharmony_ci const decode = (input, output, desc) => { 71cb0ef41Sopenharmony_ci test(function() { 81cb0ef41Sopenharmony_ci for (encoding of ["gb18030", "gbk"]) 91cb0ef41Sopenharmony_ci assert_equals(new TextDecoder(encoding).decode(new Uint8Array(input)), output) 101cb0ef41Sopenharmony_ci }, "gb18030 decoder: " + desc) 111cb0ef41Sopenharmony_ci } 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci decode([115], "s", "ASCII"); 141cb0ef41Sopenharmony_ci decode([0x80], "\u20AC", "euro"); 151cb0ef41Sopenharmony_ci decode([0xFF], "\uFFFD", "initial byte out of accepted ranges"); 161cb0ef41Sopenharmony_ci decode([0x81], "\uFFFD", "end of queue, gb18030 first not 0"); 171cb0ef41Sopenharmony_ci decode([0x81, 0x28], "\ufffd(", "two bytes 0x81 0x28"); 181cb0ef41Sopenharmony_ci decode([0x81, 0x40], "\u4E02", "two bytes 0x81 0x40"); 191cb0ef41Sopenharmony_ci decode([0x81, 0x7E], "\u4E8A", "two bytes 0x81 0x7e"); 201cb0ef41Sopenharmony_ci decode([0x81, 0x7F], "\ufffd\u007f", "two bytes 0x81 0x7f"); 211cb0ef41Sopenharmony_ci decode([0x81, 0x80], "\u4E90", "two bytes 0x81 0x80"); 221cb0ef41Sopenharmony_ci decode([0x81, 0xFE], "\u4FA2", "two bytes 0x81 0xFE"); 231cb0ef41Sopenharmony_ci decode([0x81, 0xFF], "\ufffd", "two bytes 0x81 0xFF"); 241cb0ef41Sopenharmony_ci decode([0xFE, 0x40], "\uFA0C", "two bytes 0xFE 0x40"); 251cb0ef41Sopenharmony_ci decode([0xFE, 0xFE], "\uE4C5", "two bytes 0xFE 0xFE"); 261cb0ef41Sopenharmony_ci decode([0xFE, 0xFF], "\ufffd", "two bytes 0xFE 0xFF"); 271cb0ef41Sopenharmony_ci decode([0x81, 0x30], "\ufffd", "two bytes 0x81 0x30"); 281cb0ef41Sopenharmony_ci decode([0x81, 0x30, 0xFE], "\ufffd", "three bytes 0x81 0x30 0xFE"); 291cb0ef41Sopenharmony_ci decode([0x81, 0x30, 0xFF], "\ufffd0\ufffd", "three bytes 0x81 0x30 0xFF"); 301cb0ef41Sopenharmony_ci decode([0x81, 0x30, 0xFE, 0x29], "\ufffd0\ufffd)", "four bytes 0x81 0x30 0xFE 0x29"); 311cb0ef41Sopenharmony_ci decode([0xFE, 0x39, 0xFE, 0x39], "\ufffd", "four bytes 0xFE 0x39 0xFE 0x39"); 321cb0ef41Sopenharmony_ci decode([0x81, 0x35, 0xF4, 0x36], "\u1E3E", "pointer 7458"); 331cb0ef41Sopenharmony_ci decode([0x81, 0x35, 0xF4, 0x37], "\ue7c7", "pointer 7457"); 341cb0ef41Sopenharmony_ci decode([0x81, 0x35, 0xF4, 0x38], "\u1E40", "pointer 7459"); 351cb0ef41Sopenharmony_ci decode([0x84, 0x31, 0xA4, 0x39], "\uffff", "pointer 39419"); 361cb0ef41Sopenharmony_ci decode([0x84, 0x31, 0xA5, 0x30], "\ufffd", "pointer 39420"); 371cb0ef41Sopenharmony_ci decode([0x8F, 0x39, 0xFE, 0x39], "\ufffd", "pointer 189999"); 381cb0ef41Sopenharmony_ci decode([0x90, 0x30, 0x81, 0x30], "\u{10000}", "pointer 189000"); 391cb0ef41Sopenharmony_ci decode([0xE3, 0x32, 0x9A, 0x35], "\u{10FFFF}", "pointer 1237575"); 401cb0ef41Sopenharmony_ci decode([0xE3, 0x32, 0x9A, 0x36], "\ufffd", "pointer 1237576"); 411cb0ef41Sopenharmony_ci decode([0x83, 0x36, 0xC8, 0x30], "\uE7C8", "legacy ICU special case 1"); 421cb0ef41Sopenharmony_ci decode([0xA1, 0xAD], "\u2026", "legacy ICU special case 2"); 431cb0ef41Sopenharmony_ci decode([0xA1, 0xAB], "\uFF5E", "legacy ICU special case 3"); 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci let i = 0; 461cb0ef41Sopenharmony_ci for (const range of ranges) { 471cb0ef41Sopenharmony_ci const pointer = range[0]; 481cb0ef41Sopenharmony_ci decode([ 491cb0ef41Sopenharmony_ci Math.floor(pointer / 12600) + 0x81, 501cb0ef41Sopenharmony_ci Math.floor((pointer % 12600) / 1260) + 0x30, 511cb0ef41Sopenharmony_ci Math.floor((pointer % 1260) / 10) + 0x81, 521cb0ef41Sopenharmony_ci pointer % 10 + 0x30 531cb0ef41Sopenharmony_ci ], range[1], "range " + i++); 541cb0ef41Sopenharmony_ci } 551cb0ef41Sopenharmony_ci</script> 56