Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Looking for regexp to convert hex numbers in text

by staeryatz (Monk)
on Nov 07, 2001 at 02:08 UTC ( [id://123702]=note: print w/replies, xml ) Need Help??


in reply to Looking for regexp to convert hex numbers in text

From where I learned Perl, you can do this:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
You can use pack "C" here, to convert to unsigned chars. I use this as a part of URL decoding in CGI scripts.

This packs a pair of Hex characters into an unsigned character, using the substitute function.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found