Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringIO does not set the ASCII-8BIT encoding in wb mode #3599

Closed
DataWraith opened this issue Jun 23, 2024 · 1 comment
Closed

StringIO does not set the ASCII-8BIT encoding in wb mode #3599

DataWraith opened this issue Jun 23, 2024 · 1 comment

Comments

@DataWraith
Copy link

StringIO does not set the ASCII-8BIT encoding when given the wb mode.

A minimal reproduction using the ghcr.io/graalvm/truffleruby-community Docker image is below.

TruffleRuby 24.0.1

# 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>

Ruby 3.2.2

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.

@andrykonchin
Copy link
Member

Thank you for the report, we'll look into it.

@andrykonchin andrykonchin self-assigned this Jun 28, 2024
andrykonchin added a commit to ruby/spec that referenced this issue Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants