11cb0ef41Sopenharmony_ci<!doctype html>
21cb0ef41Sopenharmony_ci<meta charset=gbk> <!-- if the server overrides this, it is stupid, as this is a testsuite -->
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     a.href = "https://example.com/?" + input
111cb0ef41Sopenharmony_ci     assert_equals(a.search.substr(1), output) // remove leading "?"
121cb0ef41Sopenharmony_ci   }, "gbk encoder: " + desc)
131cb0ef41Sopenharmony_ci }
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci encode("s", "s", "very basic")
161cb0ef41Sopenharmony_ci encode("\u20AC", "%80", "Euro")
171cb0ef41Sopenharmony_ci encode("\u4E02", "%81@", "character")
181cb0ef41Sopenharmony_ci encode("\uE4C6", "%A1@", "PUA")
191cb0ef41Sopenharmony_ci encode("\uE4C5", "%FE%FE", "PUA #2")
201cb0ef41Sopenharmony_ci encode("\ud83d\udca9", "%26%23128169%3B", "poo")
211cb0ef41Sopenharmony_ci</script>
22