URL encoding: Difference between revisions

No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 966:
 
=={{header|langur}}==
<syntaxhighlight lang="langur">val .urlEncode = ffn(.s) replace({
replace(
.s, re/[^A-Za-z0-9]/,
f(.s2) join "", map f $"%\.b:X02;"s, s2b .s2re/[^A-Za-z0-9]/,
fn(.s2) { join "", map fn .b: "%{{.b:X02}}", s2b .s2 },
)
)
}
 
writeln .urlEncode("https://some website.com/")</syntaxhighlight>
Line 1,737 ⟶ 1,739:
works like ''toPercentEncoded'' and additionally encodes a space with '+'.
Both functions work for byte sequences (characters beyond '\255\' raise the exception RANGE_ERROR).
To encode Unicode characters it is necessary to convert them to UTF-8 with ''striToUtf8'' before[https://seed7.<syntaxhighlightsourceforge.net/libraries/unicode.htm#toUtf8(in_string) lang="seed7">$toUtf8] include "seed7_05before.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "encoding.s7i";
 
Line 1,744 ⟶ 1,747:
writeln(toPercentEncoded("http://foo bar/"));
writeln(toUrlEncoded("http://foo bar/"));
end func;</syntaxhighlight>{{out}}
{{out}}
http%3A%2F%2Ffoo%20bar%2F
http%3A%2F%2Ffoo+bar%2F
Line 1,879 ⟶ 1,883:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var urlEncode = Fn.new { |url|
885

edits