Menu

[r195]: / phprpc_3.0 / js / iecompat.js  Maximize  Restore  History

Download this file

212 lines (204 with data), 9.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/**********************************************************\
| |
| The implementation of PHPRPC Protocol 3.0 |
| |
| iecompat.js |
| |
| Release 3.0.0 beta 10 |
| Copyright (c) 2005-2007 by Team-PHPRPC |
| |
| WebSite: http://www.phprpc.org/ |
| http://www.phprpc.net/ |
| http://www.phprpc.com/ |
| http://sourceforge.net/projects/php-rpc/ |
| |
| Authors: Ma Bingyao <andot@ujn.edu.cn> |
| |
| This file may be distributed and/or modified under the |
| terms of the GNU Lesser General Public License (LGPL) |
| version 2.1 as published by the Free Software Foundation |
| and appearing in the included file LICENSE. |
| |
\**********************************************************/
/* Provides missing functionality for older versions of JScript
*
* Copyright (C) 2005-2008 Ma Bingyao <andot@ujn.edu.cn>
* Version: 3.0.0 beta 8
* LastModified: Mar 9, 2007
* This library is free. You can redistribute it and/or modify it.
*/
if (typeof(encodeURIComponent) == "undefined") {
function encodeURIComponent(str) {
var l = ['%00', '%01', '%02', '%03', '%04', '%05', '%06',
'%07', '%08', '%09', '%0A', '%0B', '%0C', '%0D',
'%0E', '%0F', '%10', '%11', '%12', '%13', '%14',
'%15', '%16', '%17', '%18', '%19', '%1A', '%1B',
'%1C', '%1D', '%1E', '%1F', '%20', '!', '%22',
'%23', '%24', '%25', '%26', "'", '(', ')', '*', '%2B', '%2C',
'-', '.', '%2F', '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '%3A', '%3B', '%3C', '%3D', '%3E', '%3F',
'%40', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%5B', '%5C',
'%5D', '%5E', '_', '%60', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
'z', '%7B', '%7C', '%7D', '~', '%7F'];
var out, i, j, len, c, c2;
out = [];
len = str.length;
for(i = 0, j = 0; i < len; i++) {
c = str.charCodeAt(i);
if (c <= 0x007F) {
out[j++] = l[c];
continue;
}
else if (c <= 0x7FF) {
out[j++] = '%' + (0xC0 | ((c >> 6) & 0x1F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ( c & 0x3F)).toString(16).toUpperCase();
continue;
}
else if (c < 0xD800 || c > 0xDFFF) {
out[j++] = '%' + (0xE0 | ((c >> 12) & 0x0F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ((c >> 6) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase();
continue;
}
else {
if (++i < len) {
c2 = str.charCodeAt(i);
if (c <= 0xDBFF && 0xDC00 <= c2 && c2 <= 0xDFFF) {
c = ((c & 0x03FF) << 10 | (c2 & 0x03FF)) + 0x010000;
if (0x010000 <= c && c <= 0x10FFFF) {
out[j++] = '%' + (0xF0 | ((c >>> 18) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ((c >>> 12) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ((c >>> 6) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase();
continue;
}
}
}
}
var e = new Error(-2146823264, "The URI to be encoded contains an invalid character");
e.name = "URIError";
e.message = e.description;
throw(e);
}
return out.join('');
}
}
if (typeof(decodeURIComponent) == "undefined") {
function decodeURIComponent(str) {
function throwerror() {
var e = new Error(-2146823263, "The URI to be decoded is not a valid encoding");
e.name = "URIError";
e.message = e.description;
throw(e);
}
function checkcode() {
var d1, d2;
d1 = str.charAt(i++);
d2 = str.charAt(i++);
if (isNaN(parseInt(d1, 16)) || isNaN(parseInt(d2, 16))) {
return throwerror();
}
return parseInt(d1 + d2, 16);
}
function checkutf8() {
var c = str.charCodeAt(i++);
if (c == 37) {
if ((c = checkcode()) == null) return null;
}
if ((c >> 6) != 2) {
return throwerror();
}
}
var out, i, j, len;
var c, c2, c3, c4, s;
out = [];
len = str.length;
i = j = 0;
while(i < len) {
c = str.charCodeAt(i++);
if (c == 37) {
if ((c = checkcode()) == null) return null;
}
else {
out[j++] = String.fromCharCode(c);
continue;
}
switch(c >> 4) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
// 0xxxxxxx
out[j++] = String.fromCharCode(c);
break;
}
case 12: case 13: {
// 110x xxxx 10xx xxxx
if ((c2 = checkutf8()) == null) return null;
out[j++] = String.fromCharCode(((c & 0x1F) << 6) | (c2 & 0x3F));
break;
}
case 14: {
// 1110 xxxx 10xx xxxx 10xx xxxx
if ((c2 = checkutf8()) == null) return null;
if ((c3 = checkutf8()) == null) return null;
out[j++] = String.fromCharCode(((c & 0x0F) << 12) |
((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0));
break;
}
default: {
switch (c & 0xf) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
// 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
if ((c2 = checkutf8()) == null) return null;
if ((c3 = checkutf8()) == null) return null;
if ((c4 = checkutf8()) == null) return null;
s = ((c & 0x07) << 18) |
((c2 & 0x3f) << 12) |
((c3 & 0x3f) << 6) |
(c4 & 0x3f) - 0x10000;
if (0 <= s && s <= 0xfffff) {
out[j++] = String.fromCharCode(((s >>> 10) & 0x03ff) | 0xd800,
(s & 0x03ff) | 0xdc00);
}
else {
return throwerror();
}
break;
}
default: {
return throwerror();
}
}
}
}
}
return out.join('');
}
}
if (typeof(Array.prototype.push) == "undefined") {
Array.prototype.push = function () {
var curlen = this.length;
for (var i = 0; i < arguments.length; i++) {
this[curlen + i] = arguments[i];
}
return this.length;
}
}
if (typeof(Array.prototype.shift) == "undefined") {
Array.prototype.shift = function () {
var returnValue = this[0];
for (var i = 1; i < this.length; i++) {
this[i - 1] = this[i];
}
this.length--;
return returnValue;
}
}
if (typeof(VBArray) == "undefined") {
function VBArray() {}
VBArray.prototype.toArray = function () {
return this;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.