Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/URL-decoding/Icon/url-decoding.icon
Normal file
22
Task/URL-decoding/Icon/url-decoding.icon
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
link hexcvt
|
||||
|
||||
procedure main()
|
||||
ue := "http%3A%2F%2Ffoo%20bar%2F"
|
||||
ud := decodeURL(ue) | stop("Improperly encoded string ",image(ue))
|
||||
write("encoded = ",image(ue))
|
||||
write("decoded = ",image(ue))
|
||||
end
|
||||
|
||||
procedure decodeURL(s) #: decode URL/URI encoded data
|
||||
static de
|
||||
initial { # build lookup table for everything
|
||||
de := table()
|
||||
every de[hexstring(ord(c := !string(&ascii)),2)] := c
|
||||
}
|
||||
|
||||
c := ""
|
||||
s ? until pos(0) do # decode every %xx or fail
|
||||
c ||:= if ="%" then \de[move(2)] | fail
|
||||
else move(1)
|
||||
return c
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue