Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/URL-encoding/Icon/url-encoding.icon
Normal file
18
Task/URL-encoding/Icon/url-encoding.icon
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
link hexcvt
|
||||
|
||||
procedure main()
|
||||
write("text = ",image(u := "http://foo bar/"))
|
||||
write("encoded = ",image(ue := encodeURL(u)))
|
||||
end
|
||||
|
||||
procedure encodeURL(s) #: encode data for inclusion in a URL/URI
|
||||
static en
|
||||
initial { # build lookup table for everything
|
||||
en := table()
|
||||
every en[c := !string(~(&digits++&letters))] := "%"||hexstring(ord(c),2)
|
||||
every /en[c := !string(&cset)] := c
|
||||
}
|
||||
|
||||
every (c := "") ||:= en[!s] # re-encode everything
|
||||
return c
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue