/**********************************************************\
| |
| 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;
}
}