Function EncodeURIComponent(str)
Dim i,c,ic,s,length
length = Len(str)
For i = 1 To length
s = Mid(str,i,1)
c = "&H" & Hex(AscW(Mid(str,i,1)))
ic = CInt(c)
If ( ic >= AscW("A") And ic <= AscW("Z") ) Or _
( ic >= AscW("a") And ic <= AscW("z") ) Or _
( ic >= AscW("0") And ic <= AscW("9") ) Or _
( ic = AscW("-") Or ic = AscW("_") Or ic = AscW(".") Or ic = AscW("!") Or ic = AscW("~") Or ic = AscW("*") Or ic = AscW("'") Or ic = AscW("(") Or ic=AscW(")") ) Then
EncodeURIComponent = EncodeURIComponent & s
ElseIf ic > 16 And ic < 128 Then
EncodeURIComponent = EncodeURIComponent & "%" & Hex(ic)
Else
If c >= &H0001 And c <= &H007F Then
EncodeURIComponent = EncodeURIComponent & s
ElseIf c > &H07FF Then
EncodeURIComponent = EncodeURIComponent & "%" & Hex(&HE0 Or (c\(2^12) And &H0F))
EncodeURIComponent = EncodeURIComponent & "%" & Hex(&H80 Or (c\(2^6) And &H3F))
EncodeURIComponent = EncodeURIComponent & "%" & Hex(&H80 Or (c\(2^0) And &H3F))
Else
EncodeURIComponent = EncodeURIComponent & "%" & Hex(&HC0 Or (c\(2^6) And &H1F))
EncodeURIComponent = EncodeURIComponent & "%" & Hex(&H80 Or (c\(2^0) And &H3F))
End If
End If
Next
End Function
Title:
VBS vbscript encodeuricomponent urlencode utf8 string http post data
Description:
Function EncodeURIComponent(str) Dim i,c,ic,s,length length = Len (str) For i = 1 To length s = Mid (str,i, 1 ) c =...
...
Rating:
4