develooper Front page | perl.perl5.porters | Postings from May 2013

Re: How on earth did we manage to break pack() so badly?

Thread Previous | Thread Next
From:
Eric Brine
Date:
May 1, 2013 15:37
Subject:
Re: How on earth did we manage to break pack() so badly?
Message ID:
CALJW-qE=dj8qw-gnA6uivSasZkr=5YpQP_Hmg+LvG4YNkAeZGg@mail.gmail.com
On Wed, May 1, 2013 at 11:33 AM, Eric Brine <ikegami@adaelis.com> wrote:

> Breaking
>
> unpack("H*", "\x{DF}")  # df
>
> is not an option, so you're suggesting that
>
> unpack("H*", "\x{DF}").unpack("H*", "\x{100}")
>
> gives something different than
>
> unpack("H*", "\x{DF}\x{100}")
>
> That simply makes no sense.
>
>
If you want the hex of a string, use

unpack "H*", $s

If you want the hex of the UTF-8 encoding of a string, use

unpack "H*", encode_utf8 $s

If you want to peek inside scalars, use Dump or something other appropriate
tool.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About