Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
43
Task/URL-decoding/NetRexx/url-decoding.netrexx
Normal file
43
Task/URL-decoding/NetRexx/url-decoding.netrexx
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols nobinary
|
||||
|
||||
url = [ -
|
||||
'http%3A%2F%2Ffoo%20bar%2F', -
|
||||
'mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E', -
|
||||
'%6D%61%69%6C%74%6F%3A%22%49%72%6D%61%20%55%73%65%72%22%20%3C%69%72%6D%61%2E%75%73%65%72%40%6D%61%69%6C%2E%63%6F%6D%3E' -
|
||||
]
|
||||
|
||||
loop u_ = 0 to url.length - 1
|
||||
say url[u_]
|
||||
say DecodeURL(url[u_])
|
||||
say
|
||||
end u_
|
||||
|
||||
return
|
||||
|
||||
method DecodeURL(arg) public static
|
||||
|
||||
Parse arg encoded
|
||||
decoded = ''
|
||||
PCT = '%'
|
||||
|
||||
loop label e_ while encoded.length() > 0
|
||||
parse encoded head (PCT) +1 code +2 tail
|
||||
decoded = decoded || head
|
||||
select
|
||||
when code.strip('T').length() = 2 & code.datatype('X') then do
|
||||
code = code.x2c()
|
||||
decoded = decoded || code
|
||||
end
|
||||
when code.strip('T').length() \= 0 then do
|
||||
decoded = decoded || PCT
|
||||
tail = code || tail
|
||||
end
|
||||
otherwise do
|
||||
nop
|
||||
end
|
||||
end
|
||||
encoded = tail
|
||||
end e_
|
||||
|
||||
return decoded
|
||||
Loading…
Add table
Add a link
Reference in a new issue