<script language="vbscript"> Function urlEncode(vstrin) Dim i, strreturn, strSpecial Dim thischr, innercode Dim hight8, low8 strSpecial = " <>'""#%{}\|^~[]`&?+" strreturn = "" For i = 1 To Len(vstrin) thischr = Mid(vstrin, i, 1) If Abs(Asc(thischr)) < &HFF Then If inStr(strSpecial, thischr) > 0 Then strreturn = strreturn & "%" & Hex(Asc(thischr)) Else strreturn = strreturn & thischr End If Else innercode = Asc(thischr) If innercode < 0 Then innercode = innercode + &H10000 hight8 = (innercode And &HFF00) \ &HFF low8 = innercode And &HFF strreturn = strreturn & "%" & Hex(hight8) & "%" & Hex(low8) End If Next urlEncode = strreturn End Function </script><script language="javascript"> alert(urlEncode("哈哈")); //这样就可以用了,干嘛要转换呢? </script>
Function urlEncode(vstrin)
Dim i, strreturn, strSpecial
Dim thischr, innercode
Dim hight8, low8 strSpecial = " <>'""#%{}\|^~[]`&?+"
strreturn = ""
For i = 1 To Len(vstrin)
thischr = Mid(vstrin, i, 1)
If Abs(Asc(thischr)) < &HFF Then
If inStr(strSpecial, thischr) > 0 Then
strreturn = strreturn & "%" & Hex(Asc(thischr))
Else
strreturn = strreturn & thischr
End If
Else
innercode = Asc(thischr)
If innercode < 0 Then innercode = innercode + &H10000
hight8 = (innercode And &HFF00) \ &HFF
low8 = innercode And &HFF
strreturn = strreturn & "%" & Hex(hight8) & "%" & Hex(low8)
End If
Next
urlEncode = strreturn
End Function
</script><script language="javascript">
alert(urlEncode("哈哈")); //这样就可以用了,干嘛要转换呢?
</script>