develooper Front page | perl.perl5.porters | Postings from February 2011

[perl #84670] unpack(C => ...) on string with UTF8 FLAG without <use bytes> may return value more than 255

Thread Previous | Thread Next
From:
Eric Brine via RT
Date:
February 22, 2011 10:21
Subject:
[perl #84670] unpack(C => ...) on string with UTF8 FLAG without <use bytes> may return value more than 255
Message ID:
rt-3.6.HEAD-24085-1298398878-801.84670-15-0@perl.org
On Tue Feb 22 10:13:05 2011, ikegami@adaelis.com wrote:
> You didn't say what you expect it to do. I suppose it could throw an
> exception, but the current behaviour is quite reasonable to me.

$ perl -we'printf "%02X\n", unpack "N", "\0\0\0\x{442}"'
Character(s) in 'N' format wrapped in unpack at -e line 1.
42

$ perl -wle'printf "%02X\n", unpack "C", "\x{442}"'
442

I suppose the latter could do like the former (warn and "& 0xFF" the
input), but the latter's behaviour is so much more useful.


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