If you look at the number of state transitions (hint: count %1B instances) in the example below you can see that invoking the encoder code-point-by-code-point does not match implementations.
function encode(input, output, desc) {
test(function() {
var a = document.createElement("a") // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input
assert_equals(a.search.substr(1), output) // remove leading "?"
}, "iso-2022-jp encoder: " + desc)
}
encode("\uFF90\u4F69", "%1B$B%_PP%1B(B");
encode("\uFF90a\u4F69", "%1B$B%_%1B(Ba%1B$BPP%1B(B");
There might be a related thing here, discovered in web-platform-tests/wpt#26158 by @JKingweb, that implementations skip invoking encoders if the input is entirely in the ASCII range. (Again, something that uniquely applies to ISO-2022-JP. Form submission should be checked here as well before deciding on something.)
If you look at the number of state transitions (hint: count
%1Binstances) in the example below you can see that invoking the encoder code-point-by-code-point does not match implementations.There might be a related thing here, discovered in web-platform-tests/wpt#26158 by @JKingweb, that implementations skip invoking encoders if the input is entirely in the ASCII range. (Again, something that uniquely applies to ISO-2022-JP. Form submission should be checked here as well before deciding on something.)