blob: 312c754df0d0cc692fd68272122d9a59f674fa52 [file] [log] [blame]
<!DOCTYPE html>
<title>Encoding API: ASCII supersets</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="resources/encodings.js"></script>
<script>
// Encodings that have escape codes in 0x00-0x7F
var escape_codes = {
'iso-2022-jp': [ 0x1B ]
};
encodings_table.forEach(function(section) {
section.encodings.filter(function(encoding) {
return encoding.name !== 'replacement';
}).forEach(function(encoding) {
if (utf_encodings.indexOf(encoding.name) !== -1)
return;
test(function() {
var string = '';
var bytes = [];
for (var i = 0; i < 128; ++i) {
if (encoding.name in escape_codes && escape_codes[encoding.name].indexOf(i) !== -1)
continue;
string += String.fromCharCode(i);
bytes.push(i);
}
var decoder = new TextDecoder(encoding.name);
var decoded = decoder.decode(new Uint8Array(bytes));
assert_equals(decoded, string);
}, 'ASCII superset encoding: ' + encoding.name);
});
});
</script>