File.read ignores "rb" when ASCII incompatible encoding is specified


#1

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

e$B0J2<$N5sF0$O0U?^E*$G$7$g$&$+!#e(B

$ ./ruby -ve ‘File.read(“foo”, “rb”, :encoding => “UTF-16LE”)’
ruby 1.9.0 (2008-11-28 revision 20387) [i686-linux]
-e:1:in read': ASCII incompatible encoding needs binmode (ArgumentError) from -e:1:in

:mode => “rb” e$B$H$9$l$P%(%i!<$O=P$^$;$s!#e(B

$ ./ruby -ve ‘File.read(“foo”, :mode => “rb”, :encoding => “UTF-16LE”)’
ruby 1.9.0 (2008-11-28 revision 20387) [i686-linux]


#2

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

In message “Re: [ruby-dev:37226] File.read ignores “rb” when ASCII
incompatible encoding is specified”
on Fri, 28 Nov 2008 23:28:54 +0900, “Yusuke ENDOH” removed_email_address@domain.invalid
writes:

|e$B0J2<$N5sF0$O0U?^E*$G$7$g$&$+!#e(B
|
|$ ./ruby -ve ‘File.read(“foo”, “rb”, :encoding => “UTF-16LE”)’
|ruby 1.9.0 (2008-11-28 revision 20387) [i686-linux]
|-e:1:in read': ASCII incompatible encoding needs binmode (ArgumentError) | from -e:1:in

e$B$"$k0UL#!"0U?^E*$G$9!#e(BFile.reade$B$N0z?t$Oe(B

IO.read(name, [length [, offset]], open_args) => string

e$B$J$N$G!"Bhe(B2e$B0z?t$G;XDj$7$F$$$k$N$Oe(Bmodee$B$G$O$J$/FI$_9~$`J8;zNs$Ne(B
e$BD9$5$@$+$i$G$9!#$3$3$G$Oe(Blengthe$B$N%?%$%W%A%’%C%/$h$j$b@h$K%(%se(B
e$B%3!<%G%#%s%0$N%A%’%C%/$,F~$C$F$$$k$N$G5$$E$-$K$/$$$G$9$,!"e(B
encodinge$B;XDj$r:o$k$He(B

-e:1:in `read’: can’t convert String into Integer (TypeError)

e$B$H$$$&%(%i!<$,=P$F$A$g$C$H$O$o$+$j$d$9$$$H;W$$$^$9!#e(B

|:mode => “rb” e$B$H$9$l$P%(%i!<$O=P$^$;$s!#e(B
|
|$ ./ruby -ve ‘File.read(“foo”, :mode => “rb”, :encoding => “UTF-16LE”)’
|ruby 1.9.0 (2008-11-28 revision 20387) [i686-linux]

e$B$3$A$i$O$A$c$s$He(Bmodee$B$r;XDj$7$F$$$k$N$G%(%i!<$,=P$J$$$N$OEvA3e(B
e$B$G$9$M!#e(B

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

#3

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

2008/11/29 0:57 Yukihiro M. removed_email_address@domain.invalid:

e$B$J$N$G!"Bhe(B2e$B0z?t$G;XDj$7$F$$$k$N$Oe(Bmodee$B$G$O$J$/FI$_9~$`J8;zNs$Ne(B
e$BD9$5$@$+$i$G$9!#e(B

e$B$$!"40A4$K4*0c$$$7$F$^$7$?!#<:Ni$7$^$7$?!#e(B