June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
14
Task/URL-decoding/BaCon/url-decoding.bacon
Normal file
14
Task/URL-decoding/BaCon/url-decoding.bacon
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
FUNCTION Url_Decode$(url$)
|
||||
|
||||
LOCAL result$
|
||||
|
||||
SPLIT url$ BY "%" TO item$ SIZE total
|
||||
FOR x = 1 TO total-1
|
||||
result$ = result$ & CHR$(DEC(LEFT$(item$[x], 2))) & MID$(item$[x], 3)
|
||||
NEXT
|
||||
RETURN item$[0] & result$
|
||||
|
||||
END FUNCTION
|
||||
|
||||
PRINT Url_Decode$("http%3A%2F%2Ffoo%20bar%2F")
|
||||
PRINT Url_Decode$("google.com/search?q=%60Abdu%27l-Bah%C3%A1")
|
||||
6
Task/URL-decoding/Factor/url-decoding.factor
Normal file
6
Task/URL-decoding/Factor/url-decoding.factor
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
USING: io kernel urls.encoding ;
|
||||
IN: rosetta-code.url-decoding
|
||||
|
||||
"http%3A%2F%2Ffoo%20bar%2F"
|
||||
"google.com/search?q=%60Abdu%27l-Bah%C3%A1"
|
||||
[ url-decode print ] bi@
|
||||
24
Task/URL-decoding/Lingo/url-decoding-1.lingo
Normal file
24
Task/URL-decoding/Lingo/url-decoding-1.lingo
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
----------------------------------------
|
||||
-- URL decodes a string
|
||||
-- @param {string} str
|
||||
-- @return {string}
|
||||
----------------------------------------
|
||||
on urldecode (str)
|
||||
res = ""
|
||||
ba = bytearray()
|
||||
len = str.length
|
||||
repeat with i = 1 to len
|
||||
c = str.char[i]
|
||||
if (c = "%") then
|
||||
-- fastest hex-to-dec conversion hack based on Lingo's rgb object
|
||||
ba.writeInt8(rgb(str.char[i+1..i+2]).blue)
|
||||
i = i + 2
|
||||
else if (c = "+") then
|
||||
ba.writeInt8(32)
|
||||
else
|
||||
ba.writeInt8(chartonum(c))
|
||||
end if
|
||||
end repeat
|
||||
ba.position = 1
|
||||
return ba.readRawString(ba.length)
|
||||
end
|
||||
2
Task/URL-decoding/Lingo/url-decoding-2.lingo
Normal file
2
Task/URL-decoding/Lingo/url-decoding-2.lingo
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
put urldecode("http%3A%2F%2Ffoo%20bar%2F")
|
||||
put urldecode("google.com/search?q=%60Abdu%27l-Bah%C3%A1")
|
||||
9
Task/URL-decoding/Perl-6/url-decoding.pl6
Normal file
9
Task/URL-decoding/Perl-6/url-decoding.pl6
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
my $url = "http%3A%2F%2Ffoo%20bar%2F";
|
||||
|
||||
say $url.subst: :g,
|
||||
/'%'(<:hexdigit>**2)/,
|
||||
-> ($ord ) { chr(:16(~$ord)) }
|
||||
|
||||
# Alternately, you can use an in-place substitution:
|
||||
$url ~~ s:g[ '%' (<:hexdigit> ** 2) ] = chr :16(~$0);
|
||||
say $url;
|
||||
1
Task/URL-decoding/UNIX-Shell/url-decoding-1.sh
Normal file
1
Task/URL-decoding/UNIX-Shell/url-decoding-1.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
urldecode() { local u="${1//+/ }"; printf '%b' "${u//%/\\x}"; }
|
||||
5
Task/URL-decoding/UNIX-Shell/url-decoding-2.sh
Normal file
5
Task/URL-decoding/UNIX-Shell/url-decoding-2.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
urldecode http%3A%2F%2Ffoo%20bar%2F
|
||||
http://foo bar/
|
||||
|
||||
urldecode google.com/search?q=%60Abdu%27l-Bah%C3%A1
|
||||
google.com/search?q=`Abdu'l-Bahároot@
|
||||
Loading…
Add table
Add a link
Reference in a new issue