zoukankan      html  css  js  c++  java
  • These are useful functions when you are dealing with URL encoded URLs or POST data.

    Public Function urlDecode(s As String) As String
    	If Len(s) = 0 Then Exit Function
    	Dim i As Integer
    	Dim tmp As String
    	Dim c As String
    	For i = 1 To Len(s)
    		c = Mid$(s, i, 1)
    		If c = "+" Then c = " "
    		If c = "%" Then
    			c = Chr$("&H" + Mid$(s, i + 1, 2))
    			i = i + 2
    		End If
    		tmp = tmp + c
    	Next i
    	urlDecode = tmp
    End Function
    
    Public Function urlEncode(s As String) As String
    	If Len(s) = 0 Then Exit Function
    	
    	Dim tmp As String
    	Dim c As String
    	Dim i As Integer
    	
    	For i = 1 To Len(s)
    		c = Mid(s, i, 1)
    		If (Asc(c) >= 65 And Asc(c) <= 90) _
    		Or (Asc(c) >= 97 And Asc(c) <= 122) _
    		Or (Asc(c) >= 48 And Asc(c) <= 58) _
    		Or Asc(c) = 38 _
    		Or (Asc(c) >= 45 And Asc(c) <= 47) _
    		Or Asc(c) = 58 Or Asc(c) = 61 _
    		Or Asc(c) = 63 Or Asc(c) = 126 Then
    			tmp = tmp + c
    		Else
    			tmp = tmp + "%" + Hex(Asc(c))
    		End If
    	Next i
    	urlEncode = tmp
    End Function
  • 相关阅读:
    HttpURLConnection用法详解
    Docker应用场景
    算法1
    Postman 使用详解
    Postman用法简介
    cookie和session
    HTTP简介
    get和post的区别
    git 同步非master分支
    SparseArray类
  • 原文地址:https://www.cnblogs.com/hannover/p/2328929.html
Copyright © 2011-2022 走看看