Skip to content

Conversation

herwinw
Copy link
Member

@herwinw herwinw commented Sep 10, 2023

When providing a single encoding in the mode argument, the external encoding of the IO object is set to that encoding, the internal encoding is left blank. The ArgumentError in this case is a rather specific behaviour.

I'm marking this one as Draft for now, I'm not exactly sure if this is the intended behaviour.

When providing a single encoding in the mode argument, the external
encoding of the IO object is set to that encoding, the internal encoding
is left blank. The ArgumentError in this case is a rather specific
behaviour.
@herwinw
Copy link
Member Author

herwinw commented Sep 10, 2023

Snippet of the observed behaviour (Ruby 3.1)

irb(main):001:0> io = IO.new(1, 'w:ISO-8859-1')
=> #<IO:fd 1>
irb(main):002:0> io.internal_encoding
=> nil
irb(main):003:0> io.external_encoding
=> #<Encoding:ISO-8859-1>
irb(main):004:0> io = IO.new(1, 'w:ISO-8859-1', internal_encoding: 'ISO-8859-1')
(irb):4:in `initialize': encoding specified twice (ArgumentError)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant