URL decoding: Difference between revisions
Content added Content deleted
m (Added output.) |
(URL decoding en FreeBASIC) |
||
Line 514: | Line 514: | ||
end; |
end; |
||
end;</lang> |
end;</lang> |
||
=={{header|FreeBASIC}}== |
|||
{{trans|Liberty BASIC}} |
|||
{{trans|Pascal}} |
|||
<lang freebasic> |
|||
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 |
|||
</lang> |
|||
=={{header|Go}}== |
=={{header|Go}}== |