URL decoding: Difference between revisions
Content deleted Content added
Added Pike implementation |
Thundergnat (talk | contribs) Rename Perl 6 -> Raku, alphabetize, minor clean-up |
||
Line 266:
return 0;
}</lang>
=={{header|C++}}==▼
{{libheader|Poco}}▼
{{works with|g++}}▼
<lang cpp>#include <string>▼
#include "Poco/URI.h"▼
#include <iostream>▼
int main( ) {▼
std::string encoded( "http%3A%2F%2Ffoo%20bar%2F" ) ;▼
std::string decoded ;▼
Poco::URI::decode ( encoded , decoded ) ;▼
std::cout << encoded << " is decoded: " << decoded << " !" << std::endl ;▼
return 0 ;▼
}</lang>▼
{{out}}▼
<pre>http%3A%2F%2Ffoo%20bar%2F is decoded: http://foo bar/ !</pre>▼
=={{header|C sharp}}==
Line 308 ⟶ 291:
http://foo bar/
</pre>
▲=={{header|C++}}==
▲{{libheader|Poco}}
▲{{works with|g++}}
▲<lang cpp>#include <string>
▲#include "Poco/URI.h"
▲#include <iostream>
▲int main( ) {
▲ std::string encoded( "http%3A%2F%2Ffoo%20bar%2F" ) ;
▲ std::string decoded ;
▲ Poco::URI::decode ( encoded , decoded ) ;
▲ std::cout << encoded << " is decoded: " << decoded << " !" << std::endl ;
▲ return 0 ;
▲}</lang>
▲{{out}}
▲<pre>http%3A%2F%2Ffoo%20bar%2F is decoded: http://foo bar/ !</pre>
=={{header|Caché ObjectScript}}==
Line 1,004:
my $unencoded = uri_unescape( $encoded ) ;
print "The unencoded string is $unencoded !\n" ;</lang>
=={{header|Perl 6}}==▼
<lang perl6>my $url = "http%3A%2F%2Ffoo%20bar%2F";▼
say $url.subst: :g,▼
/'%'(<:hexdigit>**2)/,▼
-> ($ord ) { chr(:16(~$ord)) }▼
# Alternately, you can use an in-place substitution:▼
$url ~~ s:g[ '%' (<:hexdigit> ** 2) ] = chr :16(~$0);▼
say $url;</lang>▼
=={{header|Phix}}==
Line 1,124 ⟶ 1,113:
(uri-decode "http%3A%2F%2Ffoo%20bar%2F")
</lang>
(formerly Perl 6)
▲<lang perl6>my $url = "http%3A%2F%2Ffoo%20bar%2F";
▲say $url.subst: :g,
▲ /'%'(<:hexdigit>**2)/,
▲ -> ($ord ) { chr(:16(~$ord)) }
▲# Alternately, you can use an in-place substitution:
▲$url ~~ s:g[ '%' (<:hexdigit> ** 2) ] = chr :16(~$0);
▲say $url;</lang>
=={{header|Retro}}==
Line 1,400 ⟶ 1,401:
{{out}}
<pre>http://foo bar/</pre>
=={{header|TUSCRIPT}}==
<lang tuscript>
|