URL decoding: Difference between revisions

 
(7 intermediate revisions by 4 users not shown)
Line 944:
 
=={{header|langur}}==
<syntaxhighlight lang="langur">val .helper = f(.s) b2s map f toNumber(.x, 16), rest split "%", .s
val finish = fn s:b2s(map(fn x:number(x, 16), rest(split("%", s))))
val .decode = f(.fn s) :replace .(s, re/(%[0-9A-Fa-f]{2})+/, .helperfinish)
 
writeln .decode("http%3A%2F%2Ffoo%20bar%2F")
writeln .decode("google.com/search?q=%60Abdu%27l-Bah%C3%A1")
</syntaxhighlight>
 
Line 1,303 ⟶ 1,304:
mailto:"Irma User" <irma.user@mail.com>
</pre>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
uses System;
 
function URLDecode(s: string) := Uri.UnescapeDataString(s);
begin
Println(URLDecode('http%3A%2F%2Ffoo%20bar%2F'));
Println(URLDecode('google.com/search?q=%60Abdu%27l-Bah%C3%A1'));
Println(URLDecode('%25%32%35'));
end.
</syntaxhighlight>
{{out}}
<pre>
http://foo bar/
google.com/search?q=`Abdu'l-Bahá
%25
</pre>
 
 
=={{header|Perl}}==
Line 1,686 ⟶ 1,707:
works like ''fromPercentEncoded'' and additionally decodes '+' with a space.
Both functions return byte sequences.
To decode Unicode characters it is necessary to convert them from UTF-8 with ''utf8ToStri''[https://seed7.sourceforge.net/libraries/unicode.htm#fromUtf8(in_string) fromUtf8] afterwards.
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "encoding.s7i";
Line 1,905 ⟶ 1,926:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Conv
 
var urlDecode = Fn.new { |enc|
1,007

edits