in reply to Understanding pack and unpack changes for binary data between 5.8 and 5.10
If this was some generic checksum routine, you could add some validation (5.8+)
sub checksum { my $s = shift; utf8::downgrade($s, 1) or croak("Wide character in subroutine entry"); return unpack("%32C*", $s) % 65535; }
For earlier backwards compatibility, that would be
sub checksum { my $s = shift; if (defined(&utf8::downgrade)) { utf8::downgrade($s, 1) or croak("Wide character in subroutine entry"); } return unpack("%32C*", $s) % 65535; }
Update: Switched utf8->can() (method check) for defined(&) (sub check).
|
|---|