ruby / stringio

Pseudo `IO` class from/to `String`.
BSD 2-Clause "Simplified" License
36 stars 26 forks source link

Breaking Change in v3.0.9 #78

Open jherdman opened 10 months ago

jherdman commented 10 months ago

I've traced back a breaking change to v3.0.9. Here's the minimal repro:

str = "\xFE\xFFColumn1,Column2\n" + "\"value1.1\",value1.2\n"
io = StringIO.new(str)
io.gets *["\n", 8192]

In v3.0.8:

io.gets *["\n", 8192]
#=>  "\xFE\xFFColumn1,Column2\n"

In v3.0.9:

     ArgumentError:
       encoding mismatch: UTF-16BE IO with UTF-8 RS

I suspect there's some kind of action for me, but this error message is a bit opaque (i.e. what is RS?).

kou commented 9 months ago

I couldn't reproduce this.

Did you really use the script? (The script doesn't have require "stringio".)

jherdman commented 9 months ago

Ah ha! I missed a few things. Here's the revised script:

require 'stringio'

str = "\xFE\xFFColumn1,Column2\n" + "\"value1.1\",value1.2\n"
io = StringIO.new(str)
io.set_encoding_by_bom
io.gets *["\n", 8192]