Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl, /unpack("C", hex...

Is that right?

         

mdharrold

1:44 am on Jul 6, 2002 (gmt 0)

10+ Year Member



We all use the following, but what would be the opposite of:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

Is there an unpack command that would work?

DrDoc

8:27 am on Jul 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[perldoc.com...]

.. but, I guess that's not quite what you're looking for. You want a function that will take any character and return the HEX code, right?

Key_Master

6:12 pm on Jul 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might find this script useful.

[webmasterworld.com...]

Key_Master

6:01 am on Jul 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$value =~ s/([^a-zA-Z0-9_\+\.])/"%" . unpack("H*",$1)/eg;