- Function VbsEscape(ByVal Str)
- Dim I,S,C,A
- S = ""
- For I = 1 To Len(Str)
- C = Mid(Str,I,1)
- A = Ascw(C)
- If (A >= 48 And A <= 57) Or (A >= 65 And A <= 90) Or (A >= 97 And A <= 122) Then
- S = S & C
- ElseIf InStr("@*_+-./",C) > 0 Then
- S = S & C
- ElseIf A > 0 And A < 16 Then
- S = S & "%0" & Hex(A)
- ElseIf A >= 16 And A < 256 Then
- S = S & "%" & Hex(A)
- Else
- S = S & "%u" & Hex(A)
- End If
- Next
- VbsEscape = S
- End Function
- Function VbsUnEscape(ByVal Str)
- Dim I,S,C
- S = ""
- For I = 1 To Len(Str)
- C = Mid(Str,I,1)
- If Mid(Str,I,2) = "%u" And I <= Len(Str) - 5 Then
- If IsNumeric("&H" & Mid(Str,I + 2,4)) Then
- S = S & Chrw(Cint("&H" & Mid(Str,I + 2,4)))
- I = I + 5
- Else
- S = S & C
- End If
- ElseIf C = "%" And I <= Len(Str) - 2 Then
- If IsNumeric("&H" & Mid(Str,I + 1,2)) Then
- S = S & Chrw(Cint("&H" & Mid(Str,I + 1,2)))
- I = I + 2
- Else
- S = S & C
- End If
- Else
- S = S & C
- End If
- Next
- VbsUnEscape = S
- End Function
复制代码 |