Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: UTF8 URI Escaping

by Khen1950fx (Canon)
on Apr 11, 2012 at 18:08 UTC ( #964591=note: print w/ replies, xml ) Need Help??


in reply to UTF8 URI Escaping

You could use URI::Escape:

#!/usr/bin/perl -l use strict; use warnings; use URI::Escape; my $f = '%C2%A3'; my $safe = uri_escape($f); my $str = uri_unescape($safe); print uri_unescape($str);
Update: Added a test for utf8.
#!/usr/bin/perl -l use strict; use warnings; use Encode; use URI::Escape; require Encode::Detect; my $f = '%C2%A3'; my $safe = uri_escape($f); my $str = uri_unescape($safe); print my $data = uri_unescape($str); my $utf8 = decode( "Detect", $data ); binmode STDOUT, ":encoding(utf8)"; print "$utf8: Looks like utf8 to me";


Comment on Re: UTF8 URI Escaping
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964591]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2014-12-26 16:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (172 votes), past polls