• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!doctype html>
2<meta charset=iso-2022-jp> <!-- 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   }, "iso-2022-jp encoder: " + desc)
13 }
14
15 encode("s", "s", "very basic");
16 encode("\u00A5\u203Es\\\uFF90\u4F69", "%1B(J\\~s%1B(B\\%1B$B%_PP%1B(B", "basics");
17 encode("\uFF61", "%1B$B!%23%1B(B", "Katakana");
18 encode("\u0393", "%1B$B&%23%1B(B", "jis0208");
19 encode("\x0E\x0F\x1Bx", "%26%2365533%3B%26%2365533%3B%26%2365533%3Bx", "SO/SI ESC");
20 encode("\u203E\x0E\x0F\x1Bx", "%1B(J~%26%2365533%3B%26%2365533%3B%26%2365533%3Bx%1B(B", "Roman SO/SI ESC");
21 encode("\uFF61\x0E\x0F\x1Bx", "%1B$B!%23%1B(B%26%2365533%3B%26%2365533%3B%26%2365533%3Bx", "Katakana SO/SI ESC");
22 encode("\u0393\x0E\x0F\x1Bx", "%1B$B&%23%1B(B%26%2365533%3B%26%2365533%3B%26%2365533%3Bx", "jis0208 SO/SI ESC");
23 encode("\uFFFD", "%26%2365533%3B", "U+FFFD");
24 encode("\u203E\uFFFD", "%1B(J~%26%2365533%3B%1B(B", "Roman U+FFFD");
25 encode("\uFF61\uFFFD", "%1B$B!%23%1B(B%26%2365533%3B", "Katakana U+FFFD");
26 encode("\u0393\uFFFD", "%1B$B&%23%1B(B%26%2365533%3B", "jis0208 U+FFFD");
27</script>
28