Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Character conversion

by vladb (Vicar)
on Feb 22, 2006 at 17:09 UTC ( #532019=note: print w/ replies, xml ) Need Help??


in reply to Character conversion

You can convert the other way using this line of code

$str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
The reverse of what you do in your first regexp, which also could be simplified just a tiny bit like so
$str =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
_____________________
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce
the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." - Robert Wilensky, University of California


Comment on Re: Character conversion
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-04 10:56 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 (59 votes), past polls