URL encoding: Difference between revisions

→‎{{header|Perl 6}}: missing 2 in format, style tweaks
(→‎{{header|Perl 6}}: Add Perl 6 solution)
(→‎{{header|Perl 6}}: missing 2 in format, style tweaks)
Line 78:
<lang perl6>my $url = 'http://foo bar/';
 
say $url.subst(/(<-[ A..ZaZ a..z0z 0..9 ]>)/, -> $/ { sprintf *.ord.fmt("%%%0X02X", $0.ord }), :g);</lang>
 
Output:
<pre>http%3A%2F%2Ffoo%20bar%2F</pre>
<pre>
http%3A%2F%2Ffoo%20bar%2F
</pre>
 
=={{header|PicoLisp}}==
Anonymous user