[Bug #3180] getc with text mode breaks incomplete character immediately before EOF

Bug #3180: getc with text mode breaks incomplete character immediately
before EOF
http://redmine.ruby-lang.org/issues/show/3180

e$B5/I<<Te(B: Yusuke E.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$BC4Ev<Te(B: Yui NARUSE, e$B%+%F%4%je(B: M17N, Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2010-04-20 trunk 27405) [i686-linux]

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

coding: UTF-8

“e$B$&e(B” [email protected]$l$?CfESH>C<$J%U%!%$%k$r:n$ke(B

s = “e$B$”$$$&$($*e(B".force_encoding(“ASCII-8BIT”)
open(“foo.txt”, “wb”) {|f| f.write(s[0, 8]) }

IO#read e$B$G0l5$$KFI$a$P4|BTDL$je(B

open(“foo.txt”, “rt”) {|f| p f.read } #=> “e$B$”$$e(B\xE3\x81"

UTF-8 [email protected]<($9$k$He(B UTF-8 e$B$K$J$k$,!":G8e$NJ8;z$,2=$1$ke(B

open(“foo.txt”, “rt:UTF-8”) {|f| p f.chars.to_a }
#=> ["e$B$“e(B”, “e$B$$e(B”, “\u0000\u0000”]

LANG e$B$Oe(B ja_JP.UTF-8 e$B$G$9!#e(B

incomplete e$B$JJ8;z$,e(B “\0\0” e$B$K2=$1$k$N$O0U?^E*$G$7$g$&$+!#e(B
e$B4|BT$H$7$F$O!"e(B["e$B$“e(B”, “e$B$$e(B”, “\xE3”, “\x81”]
e$B$G$9!#e(B


Yusuke E. [email protected]

e$B%A%1%C%He(B #3180 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

This issue was solved with changeset r27432.
Yusuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs