Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,7 +0,0 @@
|
|||
with AWS.URL;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
procedure Decode is
|
||||
Encoded : constant String := "http%3A%2F%2Ffoo%20bar%2F";
|
||||
begin
|
||||
Put_Line (AWS.URL.Decode (Encoded));
|
||||
end Decode;
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
package URL is
|
||||
function Decode (URL : in String) return String;
|
||||
end URL;
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package body URL is
|
||||
function Decode (URL : in String) return String is
|
||||
Buffer : String (1 .. URL'Length);
|
||||
Filled : Natural := 0;
|
||||
Position : Positive := URL'First;
|
||||
begin
|
||||
while Position in URL'Range loop
|
||||
Filled := Filled + 1;
|
||||
|
||||
case URL (Position) is
|
||||
when '+' =>
|
||||
Buffer (Filled) := ' ';
|
||||
Position := Position + 1;
|
||||
when '%' =>
|
||||
Buffer (Filled) :=
|
||||
Character'Val
|
||||
(Natural'Value
|
||||
("16#" & URL (Position + 1 .. Position + 2) & "#"));
|
||||
Position := Position + 3;
|
||||
when others =>
|
||||
Buffer (Filled) := URL (Position);
|
||||
Position := Position + 1;
|
||||
end case;
|
||||
end loop;
|
||||
|
||||
return Buffer (1 .. Filled);
|
||||
end Decode;
|
||||
end URL;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
with Ada.Command_Line,
|
||||
Ada.Text_IO;
|
||||
|
||||
with URL;
|
||||
|
||||
procedure Test_URL_Decode is
|
||||
use Ada.Command_Line, Ada.Text_IO;
|
||||
begin
|
||||
if Argument_Count = 0 then
|
||||
Put_Line (URL.Decode ("http%3A%2F%2Ffoo%20bar%2F"));
|
||||
else
|
||||
for I in 1 .. Argument_Count loop
|
||||
Put_Line (URL.Decode (Argument (I)));
|
||||
end loop;
|
||||
end if;
|
||||
end Test_URL_Decode;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
val finish = fn s:b2s(map(
|
||||
less(split(s, by="%"), of=1),
|
||||
less(split(s, delim="%"), of=1),
|
||||
by=fn x:number(x, fmt=16),
|
||||
))
|
||||
val decode = fn s:replace(
|
||||
|
|
@ -8,5 +8,5 @@ val decode = fn s:replace(
|
|||
with=finish,
|
||||
)
|
||||
|
||||
writeln decode("https%3A%2F%2Fno%20more%20foo%20bars%20please%2F")
|
||||
writeln decode("http%3A%2F%2Fno%20more%20foo%20bars%20please%2F")
|
||||
writeln decode("google.com/search?q=%22unbroken%20string%22")
|
||||
|
|
|
|||
|
|
@ -1,38 +1,32 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #000080;font-style:italic;">--
|
||||
-- demo\rosetta\decode_url.exw
|
||||
-- ===========================
|
||||
--</span>
|
||||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
|
||||
<span style="color: #008080;">function</span> <span style="color: #000000;">decode_url</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">skip</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
|
||||
<span style="color: #004080;">string</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span>
|
||||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">skip</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #000000;">skip</span> <span style="color: #0000FF;">-=</span> <span style="color: #000000;">1</span>
|
||||
<span style="color: #008080;">else</span>
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">ch</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">=</span><span style="color: #008000;">'%'</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">scanres</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">2</span><span style="color: #0000FF;"><=</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #000000;">scanres</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">scanf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"#"</span><span style="color: #0000FF;">&</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">..</span><span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">2</span><span style="color: #0000FF;">],</span><span style="color: #008000;">"%x"</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">scanres</span><span style="color: #0000FF;">)!=</span><span style="color: #000000;">1</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #008000;">"decode error"</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #000000;">skip</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">2</span>
|
||||
<span style="color: #000000;">ch</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">scanres</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">][</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span>
|
||||
<span style="color: #008080;">elsif</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">=</span><span style="color: #008000;">'+'</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #000000;">ch</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">' '</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #000000;">res</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">ch</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #000000;">res</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
|
||||
-- demo\rosetta\decode_url.exw
|
||||
with javascript_semantics
|
||||
function decode_url(string s)
|
||||
integer skip = 0
|
||||
string res = ""
|
||||
for i=1 to length(s) do
|
||||
if skip then
|
||||
skip -= 1
|
||||
else
|
||||
integer ch = s[i]
|
||||
if ch='%' then
|
||||
sequence scanres = {}
|
||||
if i+2<=length(s) then
|
||||
scanres = scanf("#"&s[i+1..i+2],"%x")
|
||||
end if
|
||||
if length(scanres)!=1 then
|
||||
return "decode error"
|
||||
end if
|
||||
skip = 2
|
||||
ch = scanres[1][1]
|
||||
elsif ch='+' then
|
||||
ch = ' '
|
||||
end if
|
||||
res &= ch
|
||||
end if
|
||||
end for
|
||||
return res
|
||||
end function
|
||||
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">decode_url</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"http%3A%2F%2Ffoo%20bar%2F"</span><span style="color: #0000FF;">)})</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">decode_url</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"google.com/search?q=%60Abdu%27l-Bah%C3%A1"</span><span style="color: #0000FF;">)})</span>
|
||||
|
||||
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">wait_key</span><span style="color: #0000FF;">()</span>
|
||||
<!--
|
||||
printf(1,"%s\n",{decode_url("http%3A%2F%2Ffoo%20bar%2F")})
|
||||
printf(1,"%s\n",{decode_url("google.com/search?q=%60Abdu%27l-Bah%C3%A1")})
|
||||
wait_key()
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
[System.Web.HttpUtility]::UrlDecode("http%3A%2F%2Ffoo%20bar%2F")
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
Function RegExTest(str,patrn)
|
||||
Dim regEx
|
||||
Set regEx = New RegExp
|
||||
regEx.IgnoreCase = True
|
||||
regEx.Pattern = patrn
|
||||
RegExTest = regEx.Test(str)
|
||||
End Function
|
||||
|
||||
Function URLDecode(sStr)
|
||||
Dim str,code,a0
|
||||
str=""
|
||||
code=sStr
|
||||
code=Replace(code,"+"," ")
|
||||
While len(code)>0
|
||||
If InStr(code,"%")>0 Then
|
||||
str = str & Mid(code,1,InStr(code,"%")-1)
|
||||
code = Mid(code,InStr(code,"%"))
|
||||
a0 = UCase(Mid(code,2,1))
|
||||
If a0="U" And RegExTest(code,"^%u[0-9A-F]{4}") Then
|
||||
str = str & ChrW((Int("&H" & Mid(code,3,4))))
|
||||
code = Mid(code,7)
|
||||
ElseIf a0="E" And RegExTest(code,"^(%[0-9A-F]{2}){3}") Then
|
||||
str = str & ChrW((Int("&H" & Mid(code,2,2)) And 15) * 4096 + (Int("&H" & Mid(code,5,2)) And 63) * 64 + (Int("&H" & Mid(code,8,2)) And 63))
|
||||
code = Mid(code,10)
|
||||
ElseIf a0>="C" And a0<="D" And RegExTest(code,"^(%[0-9A-F]{2}){2}") Then
|
||||
str = str & ChrW((Int("&H" & Mid(code,2,2)) And 3) * 64 + (Int("&H" & Mid(code,5,2)) And 63))
|
||||
code = Mid(code,7)
|
||||
ElseIf (a0<="B" Or a0="F") And RegExTest(code,"^%[0-9A-F]{2}") Then
|
||||
str = str & Chr(Int("&H" & Mid(code,2,2)))
|
||||
code = Mid(code,4)
|
||||
Else
|
||||
str = str & "%"
|
||||
code = Mid(code,2)
|
||||
End If
|
||||
Else
|
||||
str = str & code
|
||||
code = ""
|
||||
End If
|
||||
Wend
|
||||
URLDecode = str
|
||||
End Function
|
||||
|
||||
url = "http%3A%2F%2Ffoo%20bar%C3%A8%2F"
|
||||
WScript.Echo "Encoded URL: " & url & vbCrLf &_
|
||||
"Decoded URL: " & UrlDecode(url)
|
||||
Loading…
Add table
Add a link
Reference in a new issue