Closed DataWraith closed 3 days ago
StringIO does not set the ASCII-8BIT encoding when given the wb mode.
StringIO
wb
A minimal reproduction using the ghcr.io/graalvm/truffleruby-community Docker image is below.
ghcr.io/graalvm/truffleruby-community
# truffleruby --version truffleruby 24.0.1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
irb(main):001:0> require 'stringio' => true irb(main):002:0> io = StringIO.new(String.new, 'wb') => #<StringIO:0x24b18> irb(main):003:0> io.write("Some Unicode characters: äöüß") => 33 irb(main):004:0> io.string => "Some Unicode characters: äöüß" irb(main):005:0> io.string.encoding => #<Encoding:UTF-8>
irb(main):001:0> require 'stringio' => true irb(main):002:0> io = StringIO.new(String.new, 'wb') => #<StringIO:0x00007f92a0cc91a8> irb(main):003:0> io.write("Some Unicode characters: äöüß") => 33 irb(main):004:0> io.string => "Some Unicode characters: \xC3\xA4\xC3\xB6\xC3\xBC\xC3\x9F" irb(main):005:0> io.string.encoding => #<Encoding:ASCII-8BIT>
Ruby 2.7 through 3.3 and JRuby also seem to return ASCII-8BIT Strings.
Thank you for the report, we'll look into it.
StringIO
does not set the ASCII-8BIT encoding when given thewb
mode.A minimal reproduction using the
ghcr.io/graalvm/truffleruby-community
Docker image is below.TruffleRuby 24.0.1
Ruby 3.2.2
Ruby 2.7 through 3.3 and JRuby also seem to return ASCII-8BIT Strings.