IO#gets with limit

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

IO#gets e$B$Ke(B limit e$B$rIU$1$F8F$V$He(B valid_encoding
e$B$8$c$J$$e(B
e$BJ8;zNs$,JV$C$F$-$^$9!#e(B

$ cat test.txt
e$B$$$m$Oe(B

$ cat t.rb
#-- coding: euc-jp --
io = open(‘test.txt’, ‘r:euc-jp’)
p s = io.gets(3)
p s.valid_encoding?

$ ruby-1.9 t.rb
“e$B$$e(B\xA4”
false

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