把中文字符转换成Utf8编码
// -将汉字转换成Utf8代码(S1)
{
var
var sa = s . split(" % ");
var retV = " ";
if(sa[0]!= " ")
{
retV = sa[0];
}
for(var I = 1;i < sa.lengthi ++)
{
if(sa[i].substring(0,1)= = " u ")
{
retV+= hex 2 utf 8(str 2 hex(sa[I])。substring(1,5)));
}
else retV+= " "+sa[I];
}
ret retV;
}
function str 2 hex(s)
{
var c = " ";
var n;
var ss = " 0123456789 abcdef ";
var digS = " ";
for(var I = 0;i < s .长度;i++)
{
c = s . charat(I);
n = ss . index of(c);
digS+= dec 2d ig(eval(n));
}
//返回值;
返回挖掘;
}
function dec 2 dig(n1)
{
var s = " ";
var N2 = 0;
for(var I = 0;I < 4;i++)
{
n2 = Math.pow(2,3-I);
if(n1 > = N2)
{
s+= ' 1 ';
n1 = n1-N2;
}
else
s+= ' 0 ';
}
return s;
}
function dig 2d EC
{
var retV = 0;
if(s . length = = 4)
{
for(var I = 0;I < 4;i++)
{
retV+= eval(s . charat(I))* math . pow(2,3-I);
}
retV retV;
}
return-1;
}
function hex 2 utf 8(s)
{
var retS = " ";
var tempS = " ";
var ss = " ";
if(s . length = = 16)
{
tempS = " 1110 "+s . substring(0,4);
tempS+= " 10 "+s . substring(4,10);
tempS+= " 10 "+s . substring(10,16);
var SSS = " 0123456789 abcdef ";
for(var I = 0;I < 3;i ++)
{
0条评论