[Ruby 1.9 - Bug #407] (Open) String#<<

e$B%A%1%C%He(B #407 e$B$,Js9p$5$l$^$7$?!#e(B (by Shyouhei U.)


Bug #407: String#<<
http://redmine.ruby-lang.org/issues/show/407

e$B5/I<<Te(B: Shyouhei U.
e$B%9%F!<%?%9e(B: Open
e$BM%@hEYe(B: Normal
e$BC4Ev<Te(B: Yui NARUSE
e$B%+%F%4%je(B:
Target version:

e$B0J2<$N$h$&$Ke(Btrunke$B$N?6$kIq$$$Oe(B1.8e$B0JA0$H0c$&$N$G$9$,!"$3$l$Oe(B1.8
e$B$N?6$kIq$$$N$[$&$,<+A3$G$O$J$$$G$7$g$&$+e(B?
256e$B$,e(B\00e$B$K$J$k$N$Oe(B
UTF-8e$B$H$7$F$be(BASCII-7BITe$B$H$7$F$b$J$s$+$*$+$7$$5$$,$7$^$9!#e(B

% trunk/bin/ruby -Ku -ve’p “ABC” << 256’
ruby 1.9.0 (2008-08-06 revision 17576) [x86_64-linux]
“ABC\x00”
% ruby_1_8/bin/ruby -Ku -ve’p “ABC” << 256’
ruby 1.8.7 (2008-08-06 revision 17572) [x86_64-linux]
-e:1:in `<<’: can’t convert Fixnum into String (TypeError)
from -e:1

e$B%A%1%C%He(B #407 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r18399.

http://redmine.ruby-lang.org/issues/show/407

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

e$B$3$N%A%1%C%H$K4XO"$7$F$k$H;W$&$N$G$9$,!"e(B

|> % ruby19 -Ku -ve’p “ABC” << 256’
|> ruby 1.9.0 (2008-09-17 revision 19392) [x86_64-freebsd7.1]
|> -e:1:in `’: 256 out of char range (RangeError)
|>
|> UTF-8 [email protected]$H$3$s$J46$8!#e(B
|> % ruby19 -Ku -ve’s=“ABC\u3042” << 256;puts s.dump’
|> ruby 1.9.0 (2008-09-17 revision 19392) [x86_64-freebsd7.1]
|> “ABC\xE3\x81\x82\xC4\x80”
|
|e$B$3$Ne(B1.9e$B$N?6$kIq$$$O$&$l$7$/$J$$$s$8$c$J$$$+$J!#e(B
|"ASCII Compatible"e$B$NDj5A$H$+$r$h!<$/9M$($k$H!"e(BASCIIe$B$NJ8;zNs$H$=$&$8$c$Je(B
|e$B$$J8;zNs$O$3$N>l9gF1$8?6$kIq$$$K$J$k$Y$-e(B(e$BL[$C$FBg$-$$J}$N%(%s%3!<%G%#%se(B
|e$B%0$KB7$($k$+!"0lN’$K%(%i!<e(B)e$B$H;W$$$^$9$h!#e(B
|# e$B$8$c$J$$$H7c$7$/;H$$$E$i$9$.$F$+$J$o$s!#e(B

e$B$H$$$&;XE&$,$"$j$^$7$?!#8D?ME*$K$O8=>u0J30$N?6$kIq$$$,E,@[email protected](B
e$B$H$O;W$o$J$$$N$G$9$,!"!Ve(Bcompatiblee$B$J$O$:$J$N$K?6$kIq$$$,0c$&e(B
e$B$N$OJQ!W$H$$$&G’CN$OM}2r$G$-$J$$$G$b$J$$$G$9!#e(B

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

In message “Re: [ruby-dev:36399] Re: [Ruby 1.9 - Bug #407] (Open)
String#<<”
on Fri, 19 Sep 2008 21:53:10 +0900, “NARUSE, Yui”
[email protected] writes:

|% ruby19 -Ku -e’
|p “\u3042” << 0x3044
|p “ABCDEF”.force_encoding(“UTF-8”) << 0x3044
|p “ABCDEF” << 0x3044’
|
|“e$B$”$$e(B"
|“ABCDEFe$B$$e(B”
|-e:3:in `’: 256 out of char range (RangeError)
|
|e$B$7$+$7!"JB$Y$F$_$k$H3N$+$K$3$l$O$*$+$7$J5sF0$G!"e(B
|e$B$3$l$N860x$O;W$&$Ke(B ASCII Compatible e$B1>!9$G$J$/!"e(B
|e$B%9%/%j%W%HFb$Ne(B 7bit clean e$B$Je(B String e$B$Ne(B encoding e$B$re(B US-ASCII [email protected](B
|e$B$N$h$&$J5$$,$7$^$9!#e(B

e$BA0$+$i$&$9$&$9;W$C$F$$$?$N$G$9$,!“e(B7bite$B%U%i%0$,$”$k0J>e!"$o$6e(B
e$B$o$6e(BUS-ASCIIe$B$K$9$kI,MW$O$J$+$C$?$N$+$b$7$l$^$;$s$M!#e(B

e$B$=$l$O$=$l$H$7$F!"$3$N;EMM$Oe(B

  • [email protected]?t$re(Bconcate$B$9$k$N$O$*$+$7$$e(B
  • 1.9e$B$G$Oe(B?ae$B$O$9$G$KJ8;zNs$K$J$C$F$$$ke(B

[email protected]$+$i9M$($k$Ke(B

e$B$N$$$:$l$+$NBP1~$,NI$$$h$&$J5$$,$7$^$9!#e(B

e$B$^$H$ae(B:

1.9.1e$BD>A0$G$9$,!"0J2<$NFs$D$rDs0F$7$^$9!#e(B

  • 7bite$BJ8;zNs$N%(%s%3!<%G%#%s%0$rFCJL07$$$7$J$$e(B
  • String#<<[email protected]?t$NFCJL07$$$r$d$a$ke(B

[email protected]@%$G$9!#e(B

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

e$B$N$$$:$l$+$NBP1~$,NI$$$h$&$J5$$,$7$^$9!#e(B

e$B$^$H$ae(B:

1.9.1e$BD>A0$G$9$,!"0J2<$NFs$D$rDs0F$7$^$9!#e(B

  • 7bite$BJ8;zNs$N%(%s%3!<%G%#%s%0$rFCJL07$$$7$J$$e(B

e$B$3$A$i$O;[email protected]$G$9!"$d$C$H$-$^$9!#e(B

e$B3N$+$K!VJ8;zNs!W$H$7$F$Ne(B String e$B$G$Oe(B String#<<Integer
e$B$O0[MM$JB8:_$J$s$Ge(B
e$B$9$,!"e(B
e$B!V%P%$%HNs!W$d!V%3!<%I%]%$%s%HNs!W$H$7$F07$&>l9g$K$OM-8z$J5!G=$J$N$G!"e(B
Binarian e$B$de(B Unicoder e$B$O:$$j$=$&$G$9!#e(B
e$B8=>u!“e(BString#setbyte
e$B$G$ODI2C$,$G$-$^$;$s$7!”$G$-$k$h$&$K$7$?$H$7$F$b!“e(B
str.setbyte(str.length, 0x41) e$B$H$$$&$N$b$A$g$C$H!”$J$N$G!#e(B

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

|> ruby 1.9.0 (2008-09-17 revision 19392) [x86_64-freebsd7.1]
e$B$N$OJQ!W$H$$$&G’CN$OM}2r$G$-$J$$$G$b$J$$$G$9!#e(B

e$B!VL[$C$FBg$-$$J}$N%(%s%3!<%G%#%s%0$KB7$($k!W!"$,8=:_$NF0$-$N0U?^$G$7$g$&!#e(B

% ruby19 -Ku -e’
p “\u3042” << 0x3044
p “ABCDEF”.force_encoding(“UTF-8”) << 0x3044
p “ABCDEF” << 0x3044’

“e$B$”$$e(B"
“ABCDEFe$B$$e(B”
-e:3:in `’: 256 out of char range (RangeError)

e$B$7$+$7!"JB$Y$F$_$k$H3N$+$K$3$l$O$*$+$7$J5sF0$G!"e(B
e$B$3$l$N860x$O;W$&$Ke(B ASCII Compatible e$B1>!9$G$J$/!"e(B
e$B%9%/%j%W%HFb$Ne(B 7bit clean e$B$Je(B String e$B$Ne(B encoding
e$B$re(B US-ASCII [email protected](B
e$B$N$h$&$J5$$,$7$^$9!#e(B

At 08:00 08/09/20, NARUSE, Yui wrote:

[email protected]@%$G$9!#e(B

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

e$B3N$+$K!VJ8;zNs!W$H$7$F$Ne(B String e$B$G$Oe(B String#<<Integer e$B$O0[MM$JB8:_$J$s$Ge(B
e$B$9$,!"e(B
e$B!V%P%$%HNs!W$d!V%3!<%I%]%$%s%HNs!W$H$7$F07$&>l9g$K$OM-8z$J5!G=$J$N$G!"e(B
Binarian e$B$de(B Unicoder e$B$O:$$j$=$&$G$9!#e(B
e$B8=>u!“e(BString#setbyte e$B$G$ODI2C$,$G$-$^$;$s$7!”$G$-$k$h$&$K$7$?$H$7$F$b!“e(B
str.setbyte(str.length, 0x41) e$B$H$$$&$N$b$A$g$C$H!”$J$N$G!#e(B

[email protected]@%$5$s$HF10U$G$9!#$7$P$i$/;D$7$F!"MM;R$r8+$?$i$I$&$G$7$g$&$+!#e(B

e$B59$7$/$*4j$$$7$^$9!#e(B Martin.

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:[email protected]

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

In message “Re: [ruby-dev:36409] Re: [Ruby 1.9 - Bug #407] (Open)
String#<<”
on Sat, 20 Sep 2008 16:02:58 +0900, Martin D.
[email protected] writes:

|>e$B!V%P%$%HNs!W$d!V%3!<%I%]%$%s%HNs!W$H$7$F07$&>l9g$K$OM-8z$J5!G=$J$N$G!"e(B
|>Binarian e$B$de(B Unicoder e$B$O:$$j$=$&$G$9!#e(B
|>e$B8=>u!“e(BString#setbyte e$B$G$ODI2C$,$G$-$^$;$s$7!”$G$-$k$h$&$K$7$?$H$7$F$b!“e(B
|>str.setbyte(str.length, 0x41) e$B$H$$$&$N$b$A$g$C$H!”$J$N$G!#e(B
|
|[email protected]@%$5$s$HF10U$G$9!#$7$P$i$/;D$7$F!"MM;R$r8+$?$i$I$&$G$7$g$&$+!#e(B

e$B$^$"!“F1$8$h$&$JJ8;zNs$G0lJ}$,e(BUS-ASCIIe$B!”$b$&0lJ}$,e(BUTF-8e$B$H$$e(B
e$B$&$h$&$J%1!<%9$O$J$/$J$j$^$7$?$+$i!"MM;R$r8+$^$7$g$&$+!#e(B

In article [email protected],
Yukihiro M. [email protected] writes:

e$B$^$"!“F1$8$h$&$JJ8;zNs$G0lJ}$,e(BUS-ASCIIe$B!”$b$&0lJ}$,e(BUTF-8e$B$H$$e(B
e$B$&$h$&$J%1!<%9$O$J$/$J$j$^$7$?$+$i!"MM;R$r8+$^$7$g$&$+!#e(B

e$B%(%s%3!<%G%#%s%0$,;XDj$5$l$F$$$J$$%U%!%$%k$K5-=R$5$l$?J8;zNse(B
e$B$Oe(B US-ASCII e$B$K$J$k$N$G!"LdBj$O$`$7$m$o$+$j$K$/$/$J$C$F$$$k$he(B
e$B$&$J5$$,$7$^$9$1$I$M$’!#e(B

In article [email protected],
Yukihiro M. [email protected] writes:

US-ASCIIe$B$NJ8;zNs$,$^$.$l9~$$N$r6X;[email protected]$&[email protected]$G$O!"Lde(B e$BBj$,2r7h$7$F$$$J$$$H$$$&$N$OM}2r$G$-$^$9$,!"!V$$7$m$o$+$j$Ke(B
e$B$/$/$J$C$F$$$k!W$H$$$&$N$O$I$&$$$&$3$H$G$7$g$&!#e(B

e$BCf?H$,e(B ASCII e$B$N$_$NJ8;zNs%j%F%i%[email protected]$C$?$N$,!"e(B
e$B:#$G$O5sF0$,JQ2=$9$k$h$&$K$J$C$?$3$H$r;X$7$F$$$^$9!#e(B

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

In message “Re: [ruby-dev:36418] Re: [Ruby 1.9 - Bug #407] (Open)
String#<<”
on Sat, 20 Sep 2008 21:02:36 +0900, Tanaka A. [email protected]
writes:

|e$BCf?H$,e(B ASCII e$B$N$_$NJ8;zNs%j%F%i%[email protected]$C$?$N$,!"e(B
|e$B:#$G$O5sF0$,JQ2=$9$k$h$&$K$J$C$?$3$H$r;X$7$F$$$^$9!#e(B

e$B$&!<$`!“F1$8%U%!%$%k$G$”$l$P%(%s%3!<%G%#%s%0$,F1$8$H$$$&!V$oe(B
e$B$+$j$d$9$5!W$r<h$k$+!“Cf?H$,e(BASCIIe$B$N$_$G$”$l$P%(%s%3!<%G%#%s%0e(B
e$B$,F1$8$H$$$&$o$+$j$d$9$5$r<h$k$+!"$H$$$&BPN)[email protected]$HM}2r$9$l$P$he(B
e$B$$$G$7$g$&$+!#e(B

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

In message “Re: [ruby-dev:36416] Re: [Ruby 1.9 - Bug #407] (Open)
String#<<”
on Sat, 20 Sep 2008 19:25:30 +0900, Tanaka A. [email protected]
writes:

|> e$B$^$"!“F1$8$h$&$JJ8;zNs$G0lJ}$,e(BUS-ASCIIe$B!”$b$&0lJ}$,e(BUTF-8e$B$H$$e(B
|> e$B$&$h$&$J%1!<%9$O$J$/$J$j$^$7$?$+$i!"MM;R$r8+$^$7$g$&$+!#e(B
|
|e$B%(%s%3!<%G%#%s%0$,;XDj$5$l$F$$$J$$%U%!%$%k$K5-=R$5$l$?J8;zNse(B
|e$B$Oe(B US-ASCII e$B$K$J$k$N$G!"LdBj$O$`$7$m$o$+$j$K$/$/$J$C$F$$$k$he(B
|e$B$&$J5$$,$7$^$9$1$I$M$’!#e(B

US-ASCIIe$B$NJ8;zNs$,$^$.$l9~$$N$r6X;[email protected]$&[email protected]$G$O!"Lde(B e$BBj$,2r7h$7$F$$$J$$$H$$$&$N$OM}2r$G$-$^$9$,!"!V$$7$m$o$+$j$Ke(B
e$B$/$/$J$C$F$$$k!W$H$$$&$N$O$I$&$$$&$3$H$G$7$g$&!#e(B

At 21:53 08/09/19, NARUSE, Yui wrote:

|> % ruby19 -Ku -ve’s=“ABC\u3042” << 256;puts s.dump’
|> ruby 1.9.0 (2008-09-17 revision 19392) [x86_64-freebsd7.1]
|> “ABC\xE3\x81\x82\xC4\x80”

e$B$3$3$Oe(B UTF-8 e$B$J$N$G!“e(B"ABC\u3042\u0100”
e$B$NJ}$O0lHLE*$J%f!<%6$Ke(B
e$B<h$C$F$:$C$H$"$j$,$?$$$+$b$7$l$^$;$s!#e(B

e$B59$7$/$*4j$$$7$^$9!#e(B Martin.

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:[email protected]