| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Encoding API: ASCII supersets</title> | 2 <title>Encoding API: ASCII supersets</title> |
| 3 <script src="../../../resources/testharness.js"></script> | 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> | 4 <script src="../../../resources/testharnessreport.js"></script> |
| 5 <script src="resources/shared.js"></script> | 5 <script src="resources/shared.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 // Encodings that have escape codes in 0x00-0x7F | 8 // Encodings that have escape codes in 0x00-0x7F |
| 9 var escape_codes = { | 9 var escape_codes = { |
| 10 'hz-gb-2312': [ 0x7E ], | 10 'iso-2022-jp': [ 0x1B ] |
| 11 'iso-2022-jp': [ 0x1B ], | |
| 12 'iso-2022-kr': [ 0x0E, 0x0F, 0x1B ] | |
| 13 }; | 11 }; |
| 14 | 12 |
| 15 encodings_table.forEach(function(section) { | 13 encodings_table.forEach(function(section) { |
| 16 section.encodings.filter(function(encoding) { | 14 section.encodings.filter(function(encoding) { |
| 17 return encoding.name !== 'replacement'; | 15 return encoding.name !== 'replacement'; |
| 18 }).forEach(function(encoding) { | 16 }).forEach(function(encoding) { |
| 19 if (utf_encodings.indexOf(encoding.name) !== -1) | 17 if (utf_encodings.indexOf(encoding.name) !== -1) |
| 20 return; | 18 return; |
| 21 | 19 |
| 22 test(function() { | 20 test(function() { |
| 23 var string = ''; | 21 var string = ''; |
| 24 var bytes = []; | 22 var bytes = []; |
| 25 for (var i = 0; i < 128; ++i) { | 23 for (var i = 0; i < 128; ++i) { |
| 26 if (encoding.name in escape_codes && escape_codes[encoding.name]
.indexOf(i) !== -1) | 24 if (encoding.name in escape_codes && escape_codes[encoding.name]
.indexOf(i) !== -1) |
| 27 continue; | 25 continue; |
| 28 string += String.fromCharCode(i); | 26 string += String.fromCharCode(i); |
| 29 bytes.push(i); | 27 bytes.push(i); |
| 30 } | 28 } |
| 31 | 29 |
| 32 var decoder = new TextDecoder(encoding.name); | 30 var decoder = new TextDecoder(encoding.name); |
| 33 var decoded = decoder.decode(new Uint8Array(bytes)); | 31 var decoded = decoder.decode(new Uint8Array(bytes)); |
| 34 assert_equals(decoded, string); | 32 assert_equals(decoded, string); |
| 35 }, 'ASCII superset encoding: ' + encoding.name); | 33 }, 'ASCII superset encoding: ' + encoding.name); |
| 36 }); | 34 }); |
| 37 }); | 35 }); |
| 38 | 36 |
| 39 </script> | 37 </script> |
| OLD | NEW |