Advertisement
3_2004-2005 VB function enhancement #131169

URLDecode Function

Decodes a URLEncoded string

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
Public Function URLDecode(sEncodedURL As String) As String
 On Error GoTo Catch
 
 Dim iLoop As Integer
 Dim sRtn As String
 Dim sTmp As String
 
 If Len(sEncodedURL) > 0 Then
 ' Loop through each char
 For iLoop = 1 To Len(sEncodedURL)
  sTmp = Mid(sEncodedURL, iLoop, 1)
  sTmp = Replace(sTmp, "+", " ")
  ' If char is % then get next two chars
  ' and convert from HEX to decimal
  If sTmp = "%" and LEN(sEncodedURL) > iLoop + 2 Then
  sTmp = Mid(sEncodedURL, iLoop + 1, 2)
  sTmp = Chr(CDec("&H" & sTmp))
  ' Increment loop by 2
  iLoop = iLoop + 2
  End If
  sRtn = sRtn & sTmp
 Next iLoop
 URLDecode = sRtn
 End If
Finally:
 Exit Function
Catch:
 URLDecode = ""
 Resume Finally
End Function
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine