URL encoding: Difference between revisions
→{{header|langur}}
No edit summary |
Langurmonkey (talk | contribs) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 966:
=={{header|langur}}==
<syntaxhighlight lang="langur">val .urlEncode =
replace(
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
<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}}
http%3A%2F%2Ffoo%20bar%2F
http%3A%2F%2Ffoo+bar%2F
Line 1,879 ⟶ 1,883:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="
var urlEncode = Fn.new { |url|
|