June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue