<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script type="text/javascript">
var Base64 = function () { };
Base64.prototype = {
str: "",
EncodeChars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
GetBytes: function () {
var _len = this.str.length;
var _bytes = [];
for (var i = 0; i < _len; i++) {
var _b = this.EncodingByUTF8(this.str.charCodeAt(i));
for (var j = 0; j < _b.length; j++) {
_bytes.push(_b[j]);
}
}
return _bytes;
},
EncodingByUTF8: function (_byte) {
if (_byte >= 0x0 && _byte <= 0x7F) {
return [_byte];
}
else if (_byte >= 0x80 && _byte <= 0x7FF) {
var b1 = (0x3 << 0x6) | (_byte >> 0x6);
var b2 = (0x1 << 0x7) | (_byte & 0x3F);
return [b1, b2];
}
else if (_byte >= 0x800 && _byte <= 0xFFFF) {
var b1 = (0x7 << 0x5) | (_byte >> 0xC);
var b2 = (0x1 << 0x7) | ((_byte >> 0x6) & 0x3F);
var b3 = (0x1 << 0x7) | (_byte & 0x3F);
return [b1, b2, b3];
}
else if (_byte >= 0x10000 && _byte <= 0x10FFFF) {
var b1 = (0xF << 0x4) | (_byte >> 0x12);
var b2 = (0x1 << 0x7) | ((_byte >> 0xC) & 0x3F);
var b3 = (0x1 << 0x7) | ((_byte >> 0x6) & 0x3F);
var b4 = (0x1 << 0x7) | (_byte & 0x3F);
return [b1, b2, b3, b4];
}
},
DecodingUTF8: function (_bytes) {
var _ch;
switch (_bytes.length) {
case 1:
if (_bytes[0] != 0) {//这里按照C#里的方式对0值不显示
_ch = String.fromCharCode(_bytes[0]);
}
break;
case 2:
_ch = String.fromCharCode(((_bytes[0] & 0x1F) << 0x6) | (_bytes[1] & 0x3F));
break;
case 3:
_ch = String.fromCharCode((((_bytes[0] & 0xF) << 0xC) | ((_bytes[1] & 0x3F) << 0x6)) | (_bytes[2] & 0x3F));
break;
case 4:
_ch = String.fromCharCode(((((_bytes[0] & 0x7) << 0x12) | ((_bytes[1] & 0x3F) << 0xC)) | ((_bytes[2] & 0x3F) << 0x6)) | (_bytes[3] & 0x3F));