IO.copy_stream doesn't convert encodings

e$B$3$s$K$A$Oe(B sheepman e$B$G$9!#e(B

e$BKhEY:Y$+$$$3$H$G62=L$G$9$,!#e(B
e$B%(%s%3!<%G%#%s%0$r;XDj$7$Fe(B open e$B$7$?e(B IO
e$B%*%V%8%’%/%H$rM?$($F$b!“e(B
IO.copy_stream e$B$,%(%s%3!<%G%#%s%0$rJQ49$7$^$;$s!#e(B
e$B$3$l$O!”$3$&$$$&$b$N$G$7$g$&$+!#e(B

$ cat t.rb

coding:euc-jp

i = File.open(‘i.txt’, ‘r:euc-jp’)
o = File.open(‘o.txt’, ‘w:sjis’)
IO.copy_stream(i, o)

$ cat i.txt
e$B4A;ze(B

$ ruby-1.9 -v t.rb
ruby 1.9.2dev (2009-05-02 trunk 23326) [i686-linux]

$ nkf --guess o.txt
EUC-JP

In article [email protected],
sheepman [email protected] writes:

e$B%(%s%3!<%G%#%s%0$r;XDj$7$Fe(B open e$B$7$?e(B IO e$B%*%V%8%’%/%H$rM?$($F$b!“e(B
IO.copy_stream e$B$,%(%s%3!<%G%#%s%0$rJQ49$7$^$;$s!#e(B
e$B$3$l$O!”$3$&$$$&$b$N$G$7$g$&$+!#e(B

e$B$$$^$N$H$3$m$=$&$$$&[email protected]$H9M$($F$$$^$9!#e(B

e$BM}M3$O$^$:%3%T!<$9$k$H$$$&$N$OL5JQ49$,4|BT$5$l$F$$$k$3$H$,B?e(B
e$B$$$H$$$&?dB,$G$9!#e(B

e$B$^$?!“e(Bcopy_length e$B$K%P%$%H?t$r;XDj$G$-!”%P%$%H?t$r;XDj$9$k%ae(B
e$B%=%C%I$O%(%s%3!<%G%#%s%0JQ49$O9T$o$J$$$H$$$&[email protected]$b$"$j$^$9!#e(B

[email protected]$7!"A0<T$O?dB,$G$9$7!“8e<T$Oe(B IO#read e$B$H$$$&Nc30$b$”$j$^e(B
e$B$9!#e(B

e$B$b$7!"A0<T$N?dB,$,@5$7$/$J$/!“JQ49$,4|BT$5$l$F$$$k$3$H$,B?$$e(B
e$B$H$$$&OC$,$”$l$PJ9$+$;$F$/[email protected]$5$$!#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