<SCRIPT language="VBScript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<script language=vbscript>
function rsB(vIn)
rsB=MidB(vIn,1)
end function
function vbChar(ss)
vbChar=Chr(ss)
end function
</script>
<script language=javascript>
var glbEncode=new Array();
function reCode(b){
var t=rsB(b)+rsB("\n");
t=escape(t).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
t=t.split("@");
var i=0,j=t.length,k;
while(++i<j)
{
k=t[i].substring(0,4);
if(!glbEncode[k])glbEncode[k]=escape(vbChar(eval("0x"+k))).substring(1,6);
t[i]=glbEncode[k]+t[i].substring(4);
}
return unescape(t.join("%"));
}
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
var str=URLEncoding("a=你啊&b=好啊");
xmlhttp.open("POST","post1.asp?"+Math.random(),false);
xmlhttp.setRequestHeader("Content-Length",str.length);
xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
xmlhttp.send(str);
alert(reCode(xmlhttp.responseBody));
</script>
reCode与bytes2BSTR作用一样,妈的编码解码的头都大了,不去理它了先,以后一定弄死它们
posted on 2006-07-18 15:17
汪杰 阅读(384)
评论(2) 编辑 收藏 引用 所属分类:
asp(javascrpt)