-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unpack(C => ...) on string with UTF8 FLAG without <use bytes> may return value more than 255 #11147
Comments
From @moonlibsCreated by @moonlibsperl5.12.0 -Mutf8 -e '$_ = "\x{442}"; print unpack ( C => $_ ), "\n"' while. but with use bytes perl5.12.0 -Mbytes -Mutf8 -e '$_ = "\x{442}"; print unpack ( C => $_ ), "\n"' It's either worth adding sub unpack into bytes.pm and fix documentation or fix this issue. Perl Info
|
From @nwc10On Tue, Feb 22, 2011 at 04:46:15AM -0800, mons @ cpan. org wrote:
It's a documented behaviour change introduced in 5.10, as described in =head1 Incompatible Changes Nicholas Clark |
The RT System itself - Status changed from 'new' to 'open' |
From @moonlibsThan maybe note this behaviuor in perldoc -f pack? c A signed char (8-bit) value. Then I expect an octet. And since it is documented, It is seems to be a good idea to add |
From @ikegamiOn Tue, Feb 22, 2011 at 7:46 AM, mons@cpan.org <perlbug-followup@perl.org>wrote:
It's doing the best it can when given garbage input. It requries a string of You didn't say what you expect it to do. I suppose it could throw an
These versions peeked into the internals and produced unpredictable results - Eric |
From @ikegamiOn Tue Feb 22 10:13:05 2011, ikegami@adaelis.com wrote:
$ perl -we'printf "%02X\n", unpack "N", "\0\0\0\x{442}"' $ perl -wle'printf "%02X\n", unpack "C", "\x{442}"' I suppose the latter could do like the former (warn and "& 0xFF" the |
From perl5-porters@ton.iguana.beIn article <rt-3.6.HEAD-24085-1298398878-801.84670-15-0@perl.org>,
Actually when I made the unicode pack/unpack patch the "C" format was perl -wle 'print ord pack("C", 1000)' perl -wle 'print ord pack("W", 1000)' So the "C" format basically works "modulo 256" I think its entirely reasonable to have the same behaviour for unpack so that unpack "C", "\x{442}" would give 66 (1090 % 256) together with a format The admittedly much more sane behaviour of returning 1090 would still be unpack "W", "\x{442}" would give 1090 This woould be completely in line with the documented (in perldoc -f pack) C An unsigned char (octet) value. "W" was always meant as the unicode sane version of "C" I can make a patch if people agree with this... |
From @khwilliamsonOn Mon, 28 Feb 2011 15:06:10 -0800, perl5-porters@ton.iguana.be wrote:
No one responded to this. It looks ok to me. |
Actually, W appears to have been added to unpack already, so the one remaining issue in this ticket is unpack C |
Isn't it kinda late to be changing unpack C now?
|
Who would be harmed from the change? People using "C" that should be using "W". Who would be helped by the change? People inadvertently passing a string of Unicode Code Points to unpack C and getting garbage. They would still get garbage, but they would start receiving a warning. I have no idea how large these groups of people are. It seems to me that adding a warning without changing the output would be the most beneficial? |
On 3/9/20 2:36 AM, Eric Brine wrote:
Isn't it kinda late to be changing unpack C now?
|$ for v in 8 10 12 14 16 18 20 22 24 26 30; do printf '5.%st: ' $v;
5.${v}t/bin/perl -wle'print unpack "C", "\x{442}"'; done 5.8t: 209
5.10t: 1090 5.12t: 1090 5.14t: 1090 5.16t: 1090 5.18t: 1090 5.20t:
1090 5.22t: 1090 5.24t: 1090 5.26t: 1090 5.30t: 1090 |
Who would be harmed from the change? People using "C" that should be
using "W".
Who would be helped by the change? People inadvertently passing a string
of Unicode Code Points to unpack C and getting garbage. They would still
get garbage, but they would start receiving a warning.
I have no idea how large these groups of people are.
It seems to me that adding a warning without changing the output would
be the most beneficial?
That sounds reasonable to me.
|
Migrated from rt.perl.org#84670 (status was 'open')
Searchable as RT84670$
The text was updated successfully, but these errors were encountered: