all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
32
Task/URL-decoding/REXX/url-decoding-2.rexx
Normal file
32
Task/URL-decoding/REXX/url-decoding-2.rexx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*REXX pgm convert an URL─encoded string ──► its original unencoded form*/
|
||||
url.1 = 'http%3A%2F%2Ffoo%20bar%2F'
|
||||
url.2 = 'mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E'
|
||||
url.3 = '%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'
|
||||
URLs=3
|
||||
do j=1 for URLs
|
||||
say url.j
|
||||
say decodeURL(url.j)
|
||||
say
|
||||
end /*j*/
|
||||
exit
|
||||
/*──────────────────────────────────DECODEURL subroutine────────────────*/
|
||||
decodeURL: procedure; parse arg encoded; decoded=''
|
||||
encoded=translate(encoded,,'+') /*special case for encoded blank.*/
|
||||
|
||||
do while length(encoded)\==0
|
||||
parse var encoded head '%' +1 code +2 tail
|
||||
decoded=decoded || head
|
||||
|
||||
select
|
||||
when length(strip(code,'T'))==2 &,
|
||||
datatype(code,'X') then decoded=decoded || x2c(code)
|
||||
when length(strip(code,'T'))\==0 then do
|
||||
decoded=decoded'%'
|
||||
tail=code || tail
|
||||
end
|
||||
otherwise nop
|
||||
end /*select*/
|
||||
encoded=tail
|
||||
end /*while*/
|
||||
|
||||
return decoded
|
||||
Loading…
Add table
Add a link
Reference in a new issue