OLD | NEW |
1 This tests the basics of the Encoding API. | 1 This is a testharness.js-based test. |
| 2 PASS Encoding API basics |
| 3 Harness: the test ran to completion. |
2 | 4 |
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | |
4 | |
5 | |
6 PASS 'TextEncoder' in window is true | |
7 PASS 'TextDecoder' in window is true | |
8 PASS 'encoding' in new TextEncoder is true | |
9 PASS 'encoding' in new TextDecoder is true | |
10 PASS typeof (new TextEncoder).encoding is "string" | |
11 PASS typeof (new TextDecoder).encoding is "string" | |
12 PASS 'encode' in new TextEncoder is true | |
13 PASS 'decode' in new TextDecoder is true | |
14 PASS typeof (new TextEncoder).encode is "function" | |
15 PASS typeof (new TextDecoder).decode is "function" | |
16 PASS (new TextEncoder).encoding is "utf-8" | |
17 PASS (new TextDecoder).encoding is "utf-8" | |
18 | |
19 test encode/decode sample - utf-8 | |
20 encoded = new TextEncoder('utf-8').encode("z¢水𝄞") | |
21 PASS JSON.stringify(toArray(encoded)) is "[122,194,162,230,176,180,240,157,132,1
58,244,143,191,189]" | |
22 PASS new TextDecoder('utf-8').decode(new Uint8Array([122,194,162,230,176,180,240
,157,132,158,244,143,191,189])) is "z¢水𝄞" | |
23 | |
24 test encode/decode sample - utf-16le | |
25 encoded = new TextEncoder('utf-16le').encode("z¢水𝄞") | |
26 PASS JSON.stringify(toArray(encoded)) is "[122,0,162,0,52,108,52,216,30,221,255,
219,253,223]" | |
27 PASS new TextDecoder('utf-16le').decode(new Uint8Array([122,0,162,0,52,108,52,21
6,30,221,255,219,253,223])) is "z¢水𝄞" | |
28 | |
29 test encode/decode sample - utf-16be | |
30 encoded = new TextEncoder('utf-16be').encode("z¢水𝄞") | |
31 PASS JSON.stringify(toArray(encoded)) is "[0,122,0,162,108,52,216,52,221,30,219,
255,223,253]" | |
32 PASS new TextDecoder('utf-16be').decode(new Uint8Array([0,122,0,162,108,52,216,5
2,221,30,219,255,223,253])) is "z¢水𝄞" | |
33 | |
34 test encode/decode sample - utf-16 | |
35 encoded = new TextEncoder('utf-16').encode("z¢水𝄞") | |
36 PASS JSON.stringify(toArray(encoded)) is "[122,0,162,0,52,108,52,216,30,221,255,
219,253,223]" | |
37 PASS new TextDecoder('utf-16').decode(new Uint8Array([122,0,162,0,52,108,52,216,
30,221,255,219,253,223])) is "z¢水𝄞" | |
38 PASS successfullyParsed is true | |
39 | |
40 TEST COMPLETE | |
41 | |
OLD | NEW |