/[suikacvs]/www/test/js/uri/decode-uri-component/duc-1.html
Suika

Contents of /www/test/js/uri/decode-uri-component/duc-1.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Thu Aug 23 15:23:50 2007 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/html
New; see <http://suika.fam.cx/gate/2005/sw/decodeURIComponent> for results

1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>decodeURIComponent (encodeURIComponent (c))</title>
5 </head>
6 <body>
7
8 <p id=test>Script is not executed yet.</p>
9
10 <ul id=result-list></ul>
11
12 <script>
13 window.onload = function () {
14 var test = document.getElementById ('test');
15 var results = document.getElementById ('result-list');
16
17 var c = function (j) {
18 test.firstChild.data = 'Testing U+' + j.toString (16) + 'XX...';
19
20 for (var i = 0; i < 0x100; i++) {
21 var code = i + 0x100 * j;
22 var v = String.fromCharCode (code);
23 var w;
24 var x;
25 try {
26 w = encodeURIComponent (v);
27 x = decodeURIComponent (w);
28 if (v != x) {
29 var li = results.appendChild (document.createElement ('li'));
30 li.innerHTML = 'X';
31 li.firstChild.data = code.toString (16).toUpperCase () + ' -> ' +
32 w + ' -> ' + encodeURIComponent (x);
33 }
34 } catch (e) {
35 var li = results.appendChild (document.createElement ('li'));
36 li.innerHTML = 'X';
37 li.firstChild.data = code.toString (16).toUpperCase () + ' -> ' +
38 w + ' -> ' + e.toString ();
39 }
40 }
41
42 j++;
43 if (j < 0x100) {
44 setTimeout (function () { c (j) }, 50);
45 } else {
46 setTimeout (function () { xc (0xD800, 0xDC) }, 50);
47 }
48 };
49 setTimeout (function () { c (0) }, 50);
50
51 var xc = function (i, jh) {
52 test.firstChild.data = 'Testing surrogate 0x' + i.toString (16) + ' 0x' +
53 jh.toString (16) + 'XX...';
54
55 for (var jl = 0x00; jl < 0x100; jl++) {
56 var j = jh * 0x100 + jl;
57 var v = String.fromCharCode (i) + String.fromCharCode (j);
58 var w;
59 var x;
60 try {
61 w = encodeURIComponent (v);
62 x = decodeURIComponent (w);
63 if (v != x) {
64 var li = results.appendChild (document.createElement ('li'));
65 li.innerHTML = 'X';
66 li.firstChild.data = i.toString (16).toUpperCase () + ', ' +
67 j.toString (16).toUpperCase () + ' -> ' +
68 w + ' -> ' + encodeURIComponent (x);
69 }
70 } catch (e) {
71 var li = results.appendChild (document.createElement ('li'));
72 li.innerHTML = 'X';
73 li.firstChild.data = i.toString (16).toUpperCase () + ', ' +
74 j.toString (16).toUpperCase () + ' -> ' +
75 w + ' -> ' + e.toString ();
76 }
77 }
78
79 jh++;
80 if (jh > 0xDF) {
81 i++;
82 jh = 0xDC;
83 }
84
85 if (i < 0xDC00) {
86 setTimeout (function () { xc (i, jh) }, 50);
87 } else {
88 test.firstChild.data = 'Done.';
89 }
90 };
91 };
92 </script>
93
94 </body>
95 </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24