11cb0ef41Sopenharmony_ci<!doctype html> 21cb0ef41Sopenharmony_ci<meta charset=big5> <!-- test breaks if the server overrides this --> 31cb0ef41Sopenharmony_ci<script src=/resources/testharness.js></script> 41cb0ef41Sopenharmony_ci<script src=/resources/testharnessreport.js></script> 51cb0ef41Sopenharmony_ci<div id=log></div> 61cb0ef41Sopenharmony_ci<script> 71cb0ef41Sopenharmony_ci function encode(input, output, desc) { 81cb0ef41Sopenharmony_ci test(function() { 91cb0ef41Sopenharmony_ci var a = document.createElement("a"); // <a> uses document encoding for URL's query 101cb0ef41Sopenharmony_ci // Append and prepend X to test for off-by-one errors 111cb0ef41Sopenharmony_ci a.href = "https://example.com/?X" + input + "X"; 121cb0ef41Sopenharmony_ci assert_equals(a.search.substr(1), "X" + output + "X"); // remove leading "?" 131cb0ef41Sopenharmony_ci }, "big5 encoder: " + desc); 141cb0ef41Sopenharmony_ci } 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci encode("ab", "ab", "very basic") 171cb0ef41Sopenharmony_ci // edge cases 181cb0ef41Sopenharmony_ci encode("\u9EA6", "%26%2340614%3B", "Highest-pointer BMP character excluded from encoder"); 191cb0ef41Sopenharmony_ci encode("\uD858\uDE6B", "%26%23156267%3B", "Highest-pointer character excluded from encoder"); 201cb0ef41Sopenharmony_ci encode("\u3000", "%A1@", "Lowest-pointer character included in encoder"); 211cb0ef41Sopenharmony_ci encode("\u20AC", "%A3%E1", "Euro; the highest-pointer character before a range of 30 unmapped pointers"); 221cb0ef41Sopenharmony_ci encode("\u4E00", "%A4@", "The lowest-pointer character after the range of 30 unmapped pointers"); 231cb0ef41Sopenharmony_ci encode("\uD85D\uDE07", "%C8%A4", "The highest-pointer character before a range of 41 unmapped pointers"); 241cb0ef41Sopenharmony_ci encode("\uFFE2", "%C8%CD", "The lowest-pointer character after the range of 41 unmapped pointers"); 251cb0ef41Sopenharmony_ci encode("\u79D4", "%FE%FE", "The last character in the index"); 261cb0ef41Sopenharmony_ci // not in index 271cb0ef41Sopenharmony_ci encode("\u2603", "%26%239731%3B", "The canonical BMP test character that is not in the index"); 281cb0ef41Sopenharmony_ci encode("\uD83D\uDCA9", "%26%23128169%3B", "The canonical astral test character that is not in the index"); 291cb0ef41Sopenharmony_ci // duplicate low bits 301cb0ef41Sopenharmony_ci encode("\uD840\uDFB5", "%FDj", "A Plane 2 character whose low 16 bits match a BMP character that has a lower pointer"); 311cb0ef41Sopenharmony_ci // prefer last 321cb0ef41Sopenharmony_ci encode("\u2550", "%F9%F9", "A duplicate-mapped code point that prefers the highest pointer in the encoder"); 331cb0ef41Sopenharmony_ci</script> 34