Pack format 'H' when the packee has insufficient and odd digits


#1

Yuguie$B$G$9!#e(B

pack format
'H’e$B$K$*$$$F!“Ho%Q%C%/%G!<%?$,e(B16e$B?J$G4q?t7e$G$”$k>l9g!"@8@.$5e(B
e$B$l$k%P%$%HNs$ND9$5$K!V%8%c%s%W!W$,8+$i$l$^$9!#e(B

[“FFF”].pack(“H1”) #=> “\xF0”
[“FFF”].pack(“H2”) #=> “\xFF”
[“FFF”].pack(“H3”) #=> “\xFF\xF0”

[“FFF”].pack(“H4”) #=> “\xFF\xF0\x00”
[“FFF”].pack(“H5”) #=> “\xFF\xF0\x00”
[“FFF”].pack(“H6”) #=> “\xFF\xF0\x00\x00”

1.8.7-p72e$B$He(Btrunke$B$GF1$8?6$k$^$$$r3NG’$7$^$7$?!#e(B

H4e$B$N>l9g$OB-$j$J$$Bhe(B4e$B%K%V%k$re(B0e$B$H8+$J$7$F!"e(B2e$B%P%$%HL$N2<0L%K%V%k$K=<$F$ke(B
e$B$N$,<+A3$J5$$,$7$^$9!#$D$^$j!"e(B

[“FFF”].pack(“H4”) #=> “\xFF\xF0”
[“FFF”].pack(“H5”) #=> “\xFF\xF0\x00”
[“FFF”].pack(“H6”) #=> “\xFF\xF0\x00”

e$B8=>u$N?6$k$^$$$O0U?^$5$l$?$b$N$G$7$g$&$+e(B?


#2

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:37283] pack format ‘H’ when the packee has
insufficient and odd digits”
on Fri, 5 Dec 2008 20:32:51 +0900, “Yugui (Yuki S.)”
removed_email_address@domain.invalid writes:

|pack format 'H’e$B$K$*$$$F!“Ho%Q%C%/%G!<%?$,e(B16e$B?J$G4q?t7e$G$”$k>l9g!"@8@.$5e(B
|e$B$l$k%P%$%HNs$ND9$5$K!V%8%c%s%W!W$,8+$i$l$^$9!#e(B

|H4e$B$N>l9g$OB-$j$J$$Bhe(B4e$B%K%V%k$re(B0e$B$H8+$J$7$F!"e(B2e$B%P%$%HL$N2<0L%K%V%k$K=<$F$ke(B
|e$B$N$,<+A3$J5$$,$7$^$9!#e(B

|e$B8=>u$N?6$k$^$$$O0U?^$5$l$?$b$N$G$7$g$&$+e(B?

e$B0U?^$7$?$b$N$G$O$J$$$G$9!#$3$3$Oe(BPerle$B$K9g$o$;$k$Y$-$@$H;W$$$^e(B
e$B$9!#$A$J$_$K:#D4$Y$?$H$3$m$G$Oe(BPerle$B$G$N7k2L$ND9$5$Oe(B

perl -le ‘print length(pack(“H1”, “FFF”))’

1

perl -le ‘print length(pack(“H2”, “FFF”))’

1

e$B0J2<!"e(BH3=>2, H4=>2, H5=>3, H6=>3, H7=>4, H8=>4, H9=>5 e$B$HB3$-e(B
e$B$^$9!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)