March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -1,12 +1,16 @@
|
|||
# syntax: GAWK -f URL_DECODING.AWK
|
||||
# syntax:
|
||||
awk '
|
||||
BEGIN {
|
||||
str = "http%3A%2F%2Ffoo%20bar%2F" # "http://foo bar/"
|
||||
printf("%s\n",str)
|
||||
while (match(str,/%/)) {
|
||||
L = substr(str,1,RSTART-1) # chars to left of "%"
|
||||
M = substr(str,RSTART+1,2) # 2 chars to right of "%"
|
||||
R = substr(str,RSTART+3) # chars to right of "%xx"
|
||||
str = sprintf("%s%c%s",L,hex2dec(M),R)
|
||||
len=length(str)
|
||||
for (i=1;i<=len;i++) {
|
||||
if ( substr(str,i,1) == "%") {
|
||||
L = substr(str,1,i-1) # chars to left of "%"
|
||||
M = substr(str,i+1,2) # 2 chars to right of "%"
|
||||
R = substr(str,i+3) # chars to right of "%xx"
|
||||
str = sprintf("%s%c%s",L,hex2dec(M),R)
|
||||
}
|
||||
}
|
||||
printf("%s\n",str)
|
||||
exit(0)
|
||||
|
|
@ -15,4 +19,4 @@ function hex2dec(s, num) {
|
|||
num = index("0123456789ABCDEF",toupper(substr(s,length(s)))) - 1
|
||||
sub(/.$/,"",s)
|
||||
return num + (length(s) ? 16*hex2dec(s) : 0)
|
||||
}
|
||||
} '
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ function u = urldecoding(s)
|
|||
u = '';
|
||||
k = 1;
|
||||
while k<=length(s)
|
||||
if s(k) == '%' && k+3 <= length(s)
|
||||
if s(k) == '%' && k+2 <= length(s)
|
||||
u = sprintf('%s%c', u, char(hex2dec(s((k+1):(k+2)))));
|
||||
k = k + 3;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
/* Rexx */
|
||||
|
||||
Do
|
||||
X = 0
|
||||
url. = ''
|
||||
X = X + 1; url.0 = X; url.X = 'http%3A%2F%2Ffoo%20bar%2F'
|
||||
|
|
@ -13,13 +11,10 @@ Do
|
|||
Say
|
||||
End u_
|
||||
|
||||
Return
|
||||
End
|
||||
Exit
|
||||
|
||||
DecodeURL:
|
||||
Procedure
|
||||
Do
|
||||
DecodeURL: Procedure
|
||||
|
||||
Parse Arg encoded
|
||||
decoded = ''
|
||||
PCT = '%'
|
||||
|
|
@ -36,13 +31,10 @@ Do
|
|||
decoded = decoded || PCT
|
||||
tail = code || tail
|
||||
End
|
||||
otherwise Do
|
||||
otherwise
|
||||
Nop
|
||||
End
|
||||
End
|
||||
encoded = tail
|
||||
End e_
|
||||
|
||||
Return decoded
|
||||
End
|
||||
Exit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue