Skip to content

Return the external encoding from GzipReader#external_encoding when converting - #177

Open
segiddins wants to merge 1 commit into
ruby:masterfrom
segiddins:segiddins/gzreader-external-encoding
Open

segiddins wants to merge 1 commit into
ruby:masterfrom
segiddins:segiddins/gzreader-external-encoding

Conversation

@segiddins

Copy link
Copy Markdown
Contributor

With both external_encoding and internal_encoding given, enc holds the internal encoding and enc2 the external one, as rb_io_extract_encoding_option returns them, but #external_encoding returned enc.

io = StringIO.new(Zlib.gzip("abc"))
Zlib::GzipReader.new(io, external_encoding: "ISO-8859-1", internal_encoding: "UTF-8").external_encoding
# expected: #<Encoding:ISO-8859-1>
# actual:   #<Encoding:UTF-8>

Fixes #81

…onverting

With both external_encoding and internal_encoding given, enc holds the internal encoding and enc2 the external one, as rb_io_extract_encoding_option returns them, but #external_encoding returned enc.

```ruby
io = StringIO.new(Zlib.gzip("abc"))
Zlib::GzipReader.new(io, external_encoding: "ISO-8859-1", internal_encoding: "UTF-8").external_encoding
# expected: #<Encoding:ISO-8859-1>
# actual:   #<Encoding:UTF-8>
```

Fixes ruby#81

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
@segiddins
segiddins force-pushed the segiddins/gzreader-external-encoding branch from 6daebda to 5ed4521 Compare October 26, 2026 19:43

This branch has not been deployed

No deployments
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.

GzipReader: internal_encoding option overwrites external_encoding

1 participant