[Bug #3179] getc with text mode returns ASCII-8BIT

Bug #3179: getc with text mode returns ASCII-8BIT
http://redmine.ruby-lang.org/issues/show/3179

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

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

coding: UTF-8

“e$B$”$$$&e(B" e$B$H$$$&%U%!%$%k$r:n$ke(B

s = “e$B$”$$$&e(B"
open(“foo.txt”, “wb”) {|f| f.write(s) }

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

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

getc e$B$9$k$H%P%$%J%[email protected]$8$K$J$ke(B

open(“foo.txt”, “rt”) do |f|
p f.getc #=> “\xE3”
p f.getc #=> “\x81”
p f.getc #=> “\x82”
end

e$B3Fe(B getc e$B$Ge(B “e$B$“e(B” “e$B$$e(B” “e$B$&e(B”
e$B$,5”$C$F$/$k$3$H$r4|BT$7$^$7$?!#e(B
LANG e$B$Oe(B ja_JP.UTF-8 e$B$G$9!#e(B


Yusuke E. [email protected]

e$B%A%1%C%He(B #3179 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 r27426.
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/3179

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

e$B;d$N$H$3$m$G$Oe(B"e$B$“e(B” “e$B$$e(B” "e$B$&e(B"e$B$,JV$j$^$9$M!#e(B

minirubye$B$Oe(BLANGe$B$r8+$J$$$N$Ge(Bexternal_encodinge$B$,e(BASCII-8BITe$B$K$Je(B
e$B$j!“e(B”\xE3" “\x81” “\x82”
e$B$,JV$j$^$9$,!"[email protected]<(E*$Ke(BUTF-8e$B$re(B
e$B;XDj$7$Fe(B

open(“foo.txt”, “rt:UTF-8”)

e$B$H$9$k$H!"$d$O$je(BUTF-8e$B$NJ8;zC10L$GF0:n$7$^$9!#e(B

In message “Re: [ruby-dev:41023] [Bug #3179] getc with text mode returns
ASCII-8BIT”
on Tue, 20 Apr 2010 21:58:03 +0900, Yusuke E.
[email protected] writes:

|e$B0J2<$NF0:n$O0U?^E*$G$7$g$&$+!#e(B
|
| # coding: UTF-8
| # “e$B$”$$$&e(B" e$B$H$$$&%U%!%$%k$r:n$ke(B
| s = “e$B$”$$$&e(B"
| open(“foo.txt”, “wb”) {|f| f.write(s) }
|
| # IO#read e$B$G0l5$$KFI$a$P4|BTDL$je(B
| open(“foo.txt”, “rt”) {|f| p f.read } #=> “e$B$”$$$&e(B"
|
| # getc e$B$9$k$H%P%$%J%[email protected]$8$K$J$ke(B
| open(“foo.txt”, “rt”) do |f|
| p f.getc #=> “\xE3”
| p f.getc #=> “\x81”
| p f.getc #=> “\x82”
| end
|
|e$B3Fe(B getc e$B$Ge(B “e$B$“e(B” “e$B$$e(B” “e$B$&e(B” e$B$,5”$C$F$/$k$3$H$r4|BT$7$^$7$?!#e(B
|LANG e$B$Oe(B ja_JP.UTF-8 e$B$G$9!#e(B

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