Public Function URLEncode(strInput As String) As String
Dim strOutput As String
Dim intAscii As Integer
Dim i As Integer
For i = 1 To Len(strInput)
intAscii = Asc(Mid(strInput, i, 1))
If ((intAscii < 58) And (intAscii > 47)) Or ((intAscii < 91) And (intAscii > 64)) Or ((intAscii < 123) And (intAscii > 96)) Then
strOutput = strOutput & Chr$(intAscii)
Else
strOutput = strOutput & IIf(intAscii < 16, "%0", "%") & Trim$(Hex$(intAscii))
End If
Next
URLEncode = strOutput
End Function
在VB中实现URLEncode转换
最新推荐文章于 2023-11-15 09:07:52 发布
博客给出了一段VB代码,定义了一个名为URLEncode的函数,用于对输入的字符串进行URL编码。函数通过遍历字符串中的每个字符,根据字符的ASCII码值判断是否为数字、字母,若不是则进行特定编码处理。
354





