[PATCH 2/2] Restore Unicode checksum algorithm

Dan Scott dscott at laurentian.ca
Wed Jun 15 15:22:09 EDT 2011


This checksum algorithm was verified to work with
3M V-series self-check machines running with encoding
Unicode, which is important to sites with large
collections of non-English materials.

Signed-off-by: Dan Scott <dscott at laurentian.ca>
---
 Sip/Checksum.pm |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/Sip/Checksum.pm b/Sip/Checksum.pm
index 77b47a7..35abb3a 100644
--- a/Sip/Checksum.pm
+++ b/Sip/Checksum.pm
@@ -65,8 +65,7 @@ sub debug_split_print {
 
 sub checksum {
     my $pkt   = shift;
-    # my $u   = unpack('%16U*', $pkt);
-    my $u     = unpack('%U*', $pkt);
+    my $u     = unpack('%16C*', $pkt);
     my $check = ($u * -1) & 0xFFFF;
     if ($debug) {
         my $total = debug_split_print($pkt);
@@ -79,7 +78,6 @@ sub checksum {
     }
 
     return $check;
-    # return (-unpack('%16U*', $pkt) & 0xFFFF);
 }
 
 sub verify_cksum {
-- 
1.7.5.4


--sdtB3X0nJg68CQEu
Content-Type: application/x-perl
Content-Disposition: attachment; filename="test_checksum.pl"
Content-Transfer-Encoding: quoted-printable

#!/usr/bin/perl=0Ause strict;=0Ause warnings;=0Ause Unicode::Normalize;=0Au=
se Encode;=0Ause Data::Dumper;=0Ause utf8;=0A=0Amy $pkt =3D encode_utf8(NFD=
(decode_utf8('s=C3=A9tait')));=0Amy $c =3D unpack('%16C*', $pkt);=0Amy $u =
=3D unpack('%U*', $pkt);=0A=0Aprintf("%04.4X\n", $c);=0Aprintf("%04.4X\n", =
$u);=0A
--sdtB3X0nJg68CQEu--


More information about the Open-ils-dev mailing list