< 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;
}
}
}
}
@if (@_jscript_version < 5)
return null;
@else
var e = new Error(-2146823264, "The URI to be encoded contains an invalid character");
e.name = "URIError";
e.message = e.description;
throw(e);
@end
}
return out.join('');
}
function decodeURI(str) {
function throwerror() {
@if (@_jscript_version < 5)
return null;
@else
var e = new Error(-2146823263, "The URI to be decoded is not a valid encoding");
e.name = "URIError";
e.message = e.description;
throw(e);
@end
}
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) {
case 35: case 36: case 38: case 43: case 44: case 47:
case 58: case 59: case 61: case 63: case 64: {
if (str.charCodeAt(i - 3) == 37) {
out[j++] = str.substr(i - 3, 3);
}
else {
out[j++] = str.substr(i - 1, 1);
}
break;
}
default: {
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)










