blob: f1477f5c844e3141ddc54bb904438695df08136e [file] [log] [blame]
<html>
<head>
<link rel="stylesheet" href="../../../../fast/js/resources/js-test-style.css">
<script src="../../../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests decoding characters in various character sets.");
function hex(number)
{
var hexDigit = "0123456789ABCDEF";
var hex = hexDigit.substr(number & 0xf, 1);
while (number > 15) {
number >>= 4;
hex = hexDigit.substr(number & 15, 1) + hex;
}
return hex;
}
function decode(charsetName, characterSequence)
{
var req = new XMLHttpRequest;
req.open('GET', 'data:text/plain,' + characterSequence, false);
req.overrideMimeType('text/plain; charset="' + charsetName + '"');
req.send('');
var code = hex(req.responseText.charCodeAt(0));
return "U+" + ("0000" + code).substr(code.length, 4);
}
function testDecode(charsetName, characterSequence, unicode)
{
shouldBe("decode('" + charsetName + "', '" + characterSequence + "')", "'" + unicode + "'");
}
testDecode('x-nextstep', '%E1', 'U+00C6');
debug('');
debug("The x-nextstep test is meant to ensure that we still support legacy encodings that are not part of ICU - it is expected that it fails in other browsers, which do not support this particular encoding. See <a href=\"http://bugs.webkit.org/show_bug.cgi?id=4195\">http://bugs.webkit.org/show_bug.cgi?id=4195</a> for more details.");
debug('');
successfullyParsed = true;
</script>
<script src="../../../../fast/js/resources/js-test-post.js"></script>
</body>
</html>