Invalid byte sequence by pack format 'A' or 'a'


#1

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

pack
formate$B$Ne(B’A’e$B$He(B’a’e$B$,%j%U%!%l%s%9%^%K%e%"%k$N!Ve(BASCIIe$BJ8;zNs!W$H$$$&@bL@e(B
e$B$KH?$7$FJ8;zNs$rC1$K%P%$%HNs$H$7$F8D?tJ,$@$1>CHq$7$F$$$^$9!#e(B

str = “\xe3\x81\x82”.force_encoding(“UTF-8”)
p str #=> "e$B$“e(B”
str = [str].pack(“A”)
p str #=> “\xE3”
p str.encoding #=> #Encoding:UTF-8

e$B7k2L$H$7$F$3$N$h$&$Ke(Bvalide$B$G$J$$%P%$%HI=8=$,@8@.$5$l$k$3$H$b$"$j$^$9!#$3e(B
e$B$l$O;EMM$G$7$g$&$+e(B?

e$B9M$(J}$H$7$F$Oe(B
(1) stre$B$,e(BUS-ASCIIe$B$^$?$Oe(BASCII-8BITe$B$G$J$1$l$PNc30$rH/@8e(B
(2) e$BLa$jCM$NJ8;zNs$re(BASCII-8BITe$B$K$9$ke(B

e$B$J$I$NA*Br;h$,$"$jF@$k$H;W$$$^$9!#e(B


#2

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

In message “Re: [ruby-dev:37278] invalid byte sequence by pack format
‘A’ or ‘a’”
on Fri, 5 Dec 2008 11:52:14 +0900, “Yugui (Yuki S.)”
removed_email_address@domain.invalid writes:

|pack formate$B$Ne(B’A’e$B$He(B’a’e$B$,%j%U%!%l%s%9%^%K%e%"%k$N!Ve(BASCIIe$BJ8;zNs!W$H$$$&@bL@e(B
|e$B$KH?$7$FJ8;zNs$rC1$K%P%$%HNs$H$7$F8D?tJ,$@$1>CHq$7$F$$$^$9!#e(B

|e$B7k2L$H$7$F$3$N$h$&$Ke(Bvalide$B$G$J$$%P%$%HI=8=$,@8@.$5$l$k$3$H$b$"$j$^$9!#$3e(B
|e$B$l$O;EMM$G$7$g$&$+e(B?

e$BJ,3d$7$F9M$($^$7$g$&!#e(B

  • e$B%F%s%W%l!<%He(BAe$B$de(Bae$B$N%+%&%s%H$O%P%$%H?t$+J8;z?t$+!#e(B

    e$B%P%$%HNs$r@8@.$9$k%F%s%W%l!<%H$H$7$F$b;H$o$l$k$3$H$b$"$je(B
    e$B$^$9$7!"%P%$%H?t$NJ}$,NI$$$H;W$$$^$9e(B

  • valide$B$G$J$$%P%$%HNs$r@8@.$9$k$3$H$O0U?^E*$+e(B

    e$B0U?^E*$G$9e(B

  • valide$B$G$J$$%P%$%HNs$K85$N%(%s%3!<%G%#%s%0$rIU2C$9$k$+!"e(B
    ASCII-8BITe$B$K$9$k$+e(B

    [ruby-dev:37294]e$B$N7k2L$H$b4XO"$9$k$H;W$$$^$9$,!"e(Bpacke$B$N7k2Le(B
    e$B$O2u$l$F$$$F$b4X78$J$$$H$$$&9M$(J}$H!“L@$i$+$K2u$l$F$$$k>le(B
    e$B9g$K$Oe(BASCII-8BITe$B$K$9$k$H$$$&9M$(J}$,$”$k$H;W$$$^$9!#8=;~e(B
    e$BE@$G$O$I$A$i$H7h$a$F$O$$$^$;$s!#e(B

e$B$H$$$&$o$1$G!“8=>u$O0U?^E*$@$,!“L@$i$+$K2u$l$F$$$k>l9g$K$Oe(B
ASCII-8BITe$B$K$9$k$H$$$&%*%W%7%g%s$O$”$j$($k!”$H$$$&$N$O;d$N7ke(B
e$BO@$G$9!#e(B

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

#3

Yukihiro M. e$B$5$s$O=q$-$^$7$?e(B:

e$BO@$G$9!#e(B
validitye$B$r8!::$7$F7k2L$N%(%s%3!<%G%#%s%0$,JQ$o$k$H$$$&A*Br;h$O!"$J$s$@$+e(B
e$B0l4S@-$,$J$/$F;H$$$E$i$=$&$G$9!#e(B

e$B$J$i$P!"$=$Ne(B2e$B$D$NA*Br;h$NCf$G$O%(%s%3!<%G%#%s%0$rJ]$D$[$&$K$J$j$^$9$,!"e(B
e$B;d$O>o$Ke(BASCII-8BITe$B$,NI$$$H;W$C$F$$$^$9!#e(B

valide$B$G$J$$J8;zNs$r@8@.$7F@$k$3$H$,0U?^Ee(B(=e$B%^%k%A%P%$%HJ8;zNs$KBP$7$F$be(B
e$B%P%$%HC10L$G=hM}$9$k$3$H$,0U?^E
e(B)e$B$@$H$9$k$H!"e(B’a’,
'A’e$B$O!"ItJ,J8;zNs$rJ#e(B
e$B<L$9$ke(Bpacke$B$G$O$J$/!"J8;zNs$N%P%$%HI=8=$rE><L$9$ke(Bpacke$B$J$N$G$O$J$$$G$7$g$&$+!#e(B


#4

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

In message “Re: [ruby-dev:37318] Re: invalid byte sequence by pack
format ‘A’ or ‘a’”
on Mon, 8 Dec 2008 20:32:12 +0900, “Yugui (Yuki S.)”
removed_email_address@domain.invalid writes:

|validitye$B$r8!::$7$F7k2L$N%(%s%3!<%G%#%s%0$,JQ$o$k$H$$$&A*Br;h$O!"$J$s$@$+e(B
|e$B0l4S@-$,$J$/$F;H$$$E$i$=$&$G$9!#e(B

e$B5$;}$A$O$o$+$j$^$9!#e(B

|e$B$J$i$P!"$=$Ne(B2e$B$D$NABr;h$NCf$G$O%(%s%3!<%G%#%s%0$rJ]$D$[$&$K$J$j$^$9$,!"e(B
|e$B;d$O>o$Ke(BASCII-8BITe$B$,NI$$$H;W$C$F$$$^$9!#e(B
|
|valide$B$G$J$$J8;zNs$r@8@.$7F@$k$3$H$,0U?^E
e(B(=e$B%^%k%A%P%$%HJ8;zNs$KBP$7$F$be(B
|e$B%P%$%HC10L$G=hM}$9$k$3$H$,0U?^E*e(B)e$B$@$H$9$k$H!"e(B’a’, 'A’e$B$O!"ItJ,J8;zNs$rJ#e(B
|e$B<L$9$ke(Bpacke$B$G$O$J$/!"J8;zNs$N%P%$%HI=8=$rE><L$9$ke(Bpacke$B$J$N$G$O$J$$$G$7$g$&$+!#e(B

e$BM}6~$+$i$O$=$&$J$N$G$9$,!"%(%s%3!<%G%#%s%0>pJs$,;D$;$k;~$K;De(B
e$B$7$F$*$+$J$$$H!"e(Bunpacke$B$N;~$K85$KLa$i$J$$%1!<%9$,A}$($^$9!#J#e(B
e$B?t$N%(%s%3!<%G%#%s%0$re(Bpacke$B$7$F$7$^$C$?;~$K$O;EJ}$,$J$$$G$9$,!"e(B
packe$B$7$?J8;zNs$N%(%s%3!<%G%#%s%0$,C10l$J$i$Pe(Bunpacke$B$G%(%s%3!<e(B
e$B%G%#%s%0>pJs$b4^$a$FLa$C$F$[$7$/$J$$$G$9$+!)e(B

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