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:
Nicholas Clark
Date:
May 1, 2013 14:47
Subject:
Re: How on earth did we manage to break pack() so badly?
Message ID:
20130501144654.GP3729@plum.flirble.org
On Wed, May 01, 2013 at 04:32:07PM +0200, demerphq wrote:
> It used to be nice and safe to do this:
> 
> print unpack("H*", $_),"\n"; # lets see what the string looks like in the raw.
> 
> 
> This is no longer an effective debugging technique. It will NOT tell
> you what your string looks like. It takes a "daddy knows best"
> attitude and tries to do the right thing depending on whether the data
> is utf8 or the data is not. Which means that this:
> 
> perl -le'unpack "H*", "\x{DF}\x{100}"'
> 
> Produces completely different results depending on which Perl you are
> on. On older perls it produces a relatively useful:
> 
> c39fc480

Add U0:

$ ./perl -le'print unpack "U0H*", "\x{DF}\x{100}"'
c39fc480

$ perl5.8.9 -le'print unpack "U0H*", "\x{DF}\x{100}"' 
c39fc480

(apparently today I am supposed to be observing the public holiday. Whether
I want to or not)

Nicholas Clark

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