Code archives/Algorithms/Urlencode / Urldecode
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This code is useful to create HTTP-requests. It won't need a huge array, like the original code and the UrlDecode-function is much faster (In text 6x) Dieser Code ist nützlich, um HTTP-Anfragen zu erstellen. Er benötigt kein großes Array, wie der original-Code. Außerdem ist die UrlDecode-Funktion schneller (Im Test ca. 6 mal) | |||||
Const HexValues$ = "0123456789ABCDEF" Function UrlEncode$(Url$) Local RetVal$ = "" For I% = 1 To Len(Url$) Char% = Asc(Mid(Url$, I%, 1)) If (Char% >= 48 And Char% <= 57) Or (Char% >= 65 And Char% <= 90) Or (Char% >= 97 And Char% <= 122) Or Char% = 43 Or Char% = 45 Or Char% = 46 Or Char% = 95 RetVal$ = RetVal$ + Chr(Char%) Else RetVal$ = RetVal$ + "%" + Right(Hex(Char%), 2) End If Next Return RetVal$ End Function Function UrlDecode$(Url$) Local RetVal$ = "" For I% = 1 To Len(Url$) If Mid(Url$, I%, 1) = "%" Then RetVal$ = RetVal$ + Chr(Instr(HexValues$, Mid(Url$, I% + 1, 1)) Shl 4 + Instr(HexValues$, Mid(Url$, I% + 2, 1)) - 17) I% = I% + 2 Else RetVal$ = RetVal$ + Mid(Url$, I%, 1) End If Next Return RetVal$ End Function |
Comments
None.
Code Archives Forum