Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/URL-decoding/FreeBASIC/url-decoding.basic
Normal file
39
Task/URL-decoding/FreeBASIC/url-decoding.basic
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
Const alphanum = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
Function ToDecimal (cadena As String, base_ As Uinteger) As Uinteger
|
||||
Dim As Uinteger i, n, result = 0
|
||||
Dim As Uinteger inlength = Len(cadena)
|
||||
|
||||
For i = 1 To inlength
|
||||
n = Instr(alphanum, Mid(Lcase(cadena),i,1)) - 1
|
||||
n *= (base_^(inlength-i))
|
||||
result += n
|
||||
Next
|
||||
Return result
|
||||
End Function
|
||||
|
||||
Function url2string(cadena As String) As String
|
||||
Dim As String c, nc, res
|
||||
|
||||
For j As Integer = 1 To Len(cadena)
|
||||
c = Mid(cadena, j, 1)
|
||||
If c = "%" Then
|
||||
nc = Chr(ToDecimal((Mid(cadena, j+1, 2)), 16))
|
||||
res &= nc
|
||||
j += 2
|
||||
Else
|
||||
res &= c
|
||||
End If
|
||||
Next j
|
||||
Return res
|
||||
End Function
|
||||
|
||||
Dim As String URL = "http%3A%2F%2Ffoo%20bar%2F"
|
||||
|
||||
Print "Supplied URL '"; URL; "'"
|
||||
Print "URL decoding '"; url2string(URL); "'"
|
||||
|
||||
URL = "google.com/search?q=%60Abdu%27l-Bah%C3%A1"
|
||||
Print !"\nSupplied URL '"; URL; "'"
|
||||
Print "URL decoding '"; url2string(URL); "'"
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue