1<!doctype html> 2<meta charset=gbk> <!-- if the server overrides this, it is stupid, as this is a testsuite --> 3<script src=/resources/testharness.js></script> 4<script src=/resources/testharnessreport.js></script> 5<div id=log></div> 6<script> 7 function encode(input, output, desc) { 8 test(function() { 9 var a = document.createElement("a") // <a> uses document encoding for URL's query 10 a.href = "https://example.com/?" + input 11 assert_equals(a.search.substr(1), output) // remove leading "?" 12 }, "gbk encoder: " + desc) 13 } 14 15 encode("s", "s", "very basic") 16 encode("\u20AC", "%80", "Euro") 17 encode("\u4E02", "%81@", "character") 18 encode("\uE4C6", "%A1@", "PUA") 19 encode("\uE4C5", "%FE%FE", "PUA #2") 20 encode("\ud83d\udca9", "%26%23128169%3B", "poo") 21</script> 22