OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script src="resources/char-decoding-utils.js"></script> |
| 4 <script> |
| 5 |
| 6 description("Test encoding behavior for sequences with invalid trail bytes"); |
| 7 |
| 8 // UTF-8 codec emits replacement characters |
| 9 testDecode('UTF-8', '%C3%22', 'U+FFFD/U+0022'); |
| 10 testDecode('UTF-8', '%E2%22', 'U+FFFD/U+0022'); |
| 11 testDecode('UTF-8', '%E2%A0%22', 'U+FFFD/U+FFFD/U+0022'); |
| 12 testDecode('UTF-8', '%F0%90%80%22', 'U+FFFD/U+FFFD/U+FFFD/U+0022'); |
| 13 |
| 14 // When a trail byte is in the ASCII range and lead+trail does not |
| 15 // encode a character, the ASCII trail byte has to be added back to |
| 16 // the stream. Otherwise, lead+trail as a whole is turned to U+FFFD. |
| 17 testDecode('EUC-KR', '%C4%22', 'U+FFFD/U+0022'); |
| 18 testDecode('EUC-KR', '%C4%5C', 'U+FFFD/U+005C'); |
| 19 testDecode('EUC-KR', '%C4%7B', 'U+FFFD/U+007B'); |
| 20 testDecode('EUC-KR', '%C6%53', 'U+FFFD/U+0053'); |
| 21 testDecode('EUC-KR', '%C7%41', 'U+FFFD/U+0041'); |
| 22 testDecode('EUC-KR', '%C7%81', 'U+FFFD'); |
| 23 testDecode('EUC-KR', '%FE%A1', 'U+FFFD'); |
| 24 |
| 25 // TODO(jshin): Add more tests for EUC-JP. |
| 26 testDecode('EUC-JP', '%8F%A1%A1', 'U+FFFD'); |
| 27 testDecode('EUC-JP', '%8F%A1%81%22', 'U+FFFD/U+FFFD/U+0022'); |
| 28 testDecode('EUC-JP', '%8F%A1%22', 'U+FFFD/U+FFFD/U+0022'); |
| 29 testDecode('EUC-JP', '%8E%8E%A1', 'U+FFFD/U+FF61'); |
| 30 testDecode('EUC-JP', '%8E%E0', 'U+FFFD/U+FFFD'); |
| 31 |
| 32 testDecode('Big5', '%A1%22', 'U+FFFD/U+0022'); |
| 33 testDecode('Big5', '%87%66', 'U+FFFD/U+0066'); |
| 34 testDecode('Big5', '%89%44', 'U+FFFD/U+0044'); |
| 35 testDecode('Big5', '%8A%63', 'U+FFFD/U+0063'); |
| 36 testDecode('Big5', '%8B%54', 'U+FFFD/U+0054'); |
| 37 testDecode('Big5', '%8D%41', 'U+FFFD/U+0041'); |
| 38 testDecode('Big5', '%9B%61', 'U+FFFD/U+0061'); |
| 39 testDecode('Big5', '%9F%4E', 'U+FFFD/U+004E'); |
| 40 testDecode('Big5', '%A0%54', 'U+FFFD/U+0054'); |
| 41 |
| 42 |
| 43 testDecode('Shift_JIS', '%82%23', 'U+FFFD/U+0023'); |
| 44 testDecode('Shift_JIS', '%82%5C', 'U+FFFD/U+005C'); |
| 45 testDecode('Shift_JIS', '%82%7A', 'U+FFFD/U+007A'); |
| 46 testDecode('Shift_JIS', '%84%61', 'U+FFFD/U+0061'); |
| 47 testDecode('Shift_JIS', '%85%7B', 'U+FFFD/U+007B'); |
| 48 testDecode('Shift_JIS', '%87%7B', 'U+FFFD/U+007B'); |
| 49 testDecode('Shift_JIS', '%98%7E', 'U+FFFD/U+007E'); |
| 50 testDecode('Shift_JIS', '%FC%5B', 'U+FFFD/U+005B'); |
| 51 |
| 52 // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=28141#c4 |
| 53 // We're different from the encoding spec as of 2015-03-18. |
| 54 testDecode('shift_jis', '%EB%9F', 'U+FFFD'); |
| 55 |
| 56 </script> |
OLD | NEW |