From: Nick Ing-Simmons Date: Sun, 8 Oct 2000 13:16:33 +0000 (+0000) Subject: Tables assume network byte order for 16 bit forms, so 'S' packing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5dcbab342366e23215fe343c50f656558418f409;p=p5sagit%2Fp5-mst-13.2.git Tables assume network byte order for 16 bit forms, so 'S' packing is not right thing to do on (e.g. x86). Network order is also "right" for X fonts. p4raw-id: //depot/perl@7168 --- diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index 9d5e07f..8ba7232 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -469,9 +469,9 @@ sub name { shift->{'Name'} } sub rep_S { 'C' } -sub rep_D { 'S' } +sub rep_D { 'n' } -sub rep_M { ($_[0] > 255) ? 'S' : 'C' } +sub rep_M { ($_[0] > 255) ? 'n' : 'C' } sub representation { @@ -542,7 +542,7 @@ sub toUnicode my $uni = ''; while (length($str)) { - my $code = unpack('S',substr($str,0,2,'')); + my $code = unpack('n',substr($str,0,2,'')) & 0xffff; $uni .= chr($code); } $_[1] = $str if $chk; @@ -562,7 +562,7 @@ sub fromUnicode last if ($chk); $x = 0; } - $str .= pack('S',$x); + $str .= pack('n',$x); } $_[1] = $uni if $chk; return $str;