Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,48 @@
/* Rexx */
Do
X = 0
url. = ''
X = X + 1; url.0 = X; url.X = 'http%3A%2F%2Ffoo%20bar%2F'
X = X + 1; url.0 = X; url.X = 'mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E'
X = X + 1; url.0 = X; url.X = '%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'
Do u_ = 1 to url.0
Say url.u_
Say DecodeURL(url.u_)
Say
End u_
Return
End
Exit
DecodeURL:
Procedure
Do
Parse Arg encoded
decoded = ''
PCT = '%'
Do while length(encoded) > 0
Parse Var encoded head (PCT) +1 code +2 tail
decoded = decoded || head
Select
When length(strip(code, 'T')) = 2 & datatype(code, 'X') then Do
code = x2c(code)
decoded = decoded || code
End
When length(strip(code, 'T')) \= 0 then Do
decoded = decoded || PCT
tail = code || tail
End
Otherwise Do
Nop
End
End
encoded = tail
End
Return decoded
End
Exit

View file

@ -0,0 +1,29 @@
/*REXX program converts a 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: procedure; parse arg encoded; decoded= ''
do while encoded\==''
parse var encoded head '%' +1 code +2 tail
decoded= decoded || head
L= length( strip( code, 'T') )
select
when L==2 & datatype(code, "X") then decoded= decoded || x2c(code)
when L\==0 then do; decoded= decoded'%'
tail= code || tail
end
otherwise nop
end /*select*/
encoded= tail
end /*while*/
return decoded

View file

@ -0,0 +1,22 @@
/*REXX program converts & displays a URL─encoded string ──► its original unencoded form.*/
url. =
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'
do j=1 until url.j==''; say /*process each URL; display blank line.*/
say url.j /*display the original URL. */
say URLdecode(url.j) /* " " decoded " */
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
URLdecode: procedure; parse arg yyy /*get encoded URL from argument list. */
yyy= translate(yyy, , '+') /*a special case for an encoded blank. */
URL=
do until yyy==''
parse var yyy plain '%' +1 code +2 yyy
URL= URL || plain
if datatype(code, 'X') then URL= URL || x2c(code)
else URL= URL'%'code
end /*until*/
return URL