ASP 将URL编码为UTF-8格式:
Function URLEncodetoUTF8(url)
Dim oneChar, result
Dim oneAsc
If url = "" Then
URLEncodetoUTF8 = url
Exit Function
End If
For i = 1 To Len(url)
oneChar = Mid(url,i, 1)
oneAsc = AscW(oneChar)
If oneAsc < 0 Then oneAsc = oneAsc + 65536
If (oneAsc And &HFF80) = 0 Then
If (oneAsc >= 65 And oneAsc <= 90) or (oneAsc >= 97 And oneAsc <= 122) or (oneAsc >= 48 And oneAsc <= 57) or oneAsc = 45 or oneAsc = 46 or oneAsc = 95 Then
result = result & oneChar
Else
result = result & "%" & Hex(oneAsc)
End If
Else
If (oneAsc And &HF000) = 0 Then
uch = "%" & Hex(((oneAsc \ 2 ^ 6)) or &HC0) & Hex(oneAsc And &H3F or &H80)
result = result & uch
Else
uch = "%" & Hex((oneAsc \ 2 ^ 12) or &HE0) & "%" & _
Hex((oneAsc \ 2 ^ 6) And &H3F or &H80) & "%" & _
Hex(oneAsc And &H3F or &H80)
result = result & uch
End If
End If
Next
URLEncodetoUTF8 = result
End Function |
文章作者
Nuclear'Atk
上次更新
2010-09-11
许可协议
Nuclear'Atk(核攻击)网络安全实验室版权所有,转载请注明出处。