Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: UTF8 URI Escaping

by Eliya (Vicar)
on Apr 11, 2012 at 11:24 UTC ( #964508=note: print w/ replies, xml ) Need Help??


in reply to UTF8 URI Escaping

The two octet sequence c2 a3 is the UTF-8 encoding of the pound character, so for Perl to treat it as one single character, you need to decode it:

use Encode; my $f = "%C2%A3"; $f =~ s/%([a-fA-F0-9]{2})/pack('C', hex($1))/eg; my $decoded = decode("UTF-8", $f);

And then, depending on what you want to do with the decoded string on the output side, you might want to encode it again — usually done via setting the appropriate PerlIO encoding layer for the respective file handle.


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://964508]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-08 00:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls