charset.html (1971B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>JSON modules: UTF-8 decoding</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id=log></div> 7 <script type="module" onerror="unreachable()"> 8 import json from "../serve-with-content-type.py?fn=json-module/utf-8.json&ct=text/json%3Bcharset=utf-8" with { type: "json"}; 9 test(() => { 10 assert_equals(json.data, "śćążź"); 11 }, "JSON module should be loaded as utf-8 when charset=utf8 is specified"); 12 </script> 13 <script type="module" onerror="unreachable()"> 14 import json from "../serve-with-content-type.py?fn=json-module/utf-8.json&ct=text/json%3Bcharset=shift-jis" with { type: "json"}; 15 test(() => { 16 assert_equals(json.data, "śćążź"); 17 }, "JSON module should be loaded as utf-8 when charset=shift-jis is specified"); 18 </script> 19 <script type="module" onerror="unreachable()"> 20 import json from "../serve-with-content-type.py?fn=json-module/utf-8.json&ct=text/json%3Bcharset=windows-1252" with { type: "json"}; 21 test(() => { 22 assert_equals(json.data, "śćążź"); 23 }, "JSON module should be loaded as utf-8 when charset=windows-1252 is specified"); 24 </script> 25 <script type="module" onerror="unreachable()"> 26 import json from "../serve-with-content-type.py?fn=json-module/utf-8.json&ct=text/json%3Bcharset=utf-7" with { type: "json"};; 27 test(() => { 28 assert_equals(json.data, "śćążź"); 29 }, "JSON module should be loaded as utf-8 when charset=utf-7 is specified"); 30 </script> 31 <script type="module" onerror="unreachable()"> 32 import json from "../serve-with-content-type.py?fn=json-module/windows-1250.json&ct=text/json%3Bcharset=windows-1250" with { type: "json"}; 33 test(() => { 34 assert_not_equals(json.data, "śćążź", 35 'Should be decoded as UTF-8'); 36 }, "JSON module should be loaded as utf-8 even if it is encoded in windows-1250 and served with a windows-1250 charset response header"); 37 </script>