all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
24
Task/URL-encoding/AWK/url-encoding.awk
Normal file
24
Task/URL-encoding/AWK/url-encoding.awk
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
BEGIN {
|
||||
for (i = 0; i <= 255; i++)
|
||||
ord[sprintf("%c", i)] = i
|
||||
}
|
||||
|
||||
# Encode string with application/x-www-form-urlencoded escapes.
|
||||
function escape(str, c, len, res) {
|
||||
len = length(str)
|
||||
res = ""
|
||||
for (i = 1; i <= len; i++) {
|
||||
c = substr(str, i, 1);
|
||||
if (c ~ /[0-9A-Za-z]/)
|
||||
#if (c ~ /[-._*0-9A-Za-z]/)
|
||||
res = res c
|
||||
#else if (c == " ")
|
||||
# res = res "+"
|
||||
else
|
||||
res = res "%" sprintf("%02X", ord[c])
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
# Escape every line of input.
|
||||
{ print escape($0) }
|
||||
Loading…
Add table
Add a link
Reference in a new issue