GzipReader: internal_encoding option overwrites external_encoding
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 73
- Forks
- 40
- Avg merge
- 10h 32m
- Merged PRs (30d)
- 2
Description
(Ruby version 3.3.1)
Hi!
When I specify the internal_encoding option to GzipReader.open or GzipReader.new, this seems to override whatever was set by the external_encoding option.
Example:
When not specifying internal_encoding, we get the expected external_encoding:
Zlib::GzipReader.open('myfile.gz', external_encoding: 'iso-8859-1') do |gz|
puts gz.external_encoding
end
output:
ISO-8859-1
But with internal_encoding specified, external_encoding is changed:
Zlib::GzipReader.open('myfile.gz', external_encoding: 'iso-8859-1', internal_encoding: 'utf-8') do |gz|
puts gz.external_encoding
end
output:
UTF-8
This seems broken, right? I'm not getting the problem with File.open.
Additionally, I noticed GzipReader does not respond to internal_encoding:
Zlib::GzipReader.open('myfile.gz') do |gz|
puts gz.internal_encoding
end
This throws NoMethodError with message:
undefined method `internal_encoding' for #<Zlib::GzipReader:0x00007f4c616a4e10> (NoMethodError)
Did you mean? external_encoding
Regards,
Olof
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two GzipReader examples from the issue on Ruby 3.3.1 and compare their encoding behavior with File.open. Trace the GzipReader API and encoding handling in the zlib repository; done means external_encoding remains ISO-8859-1 when internal_encoding is also supplied and the expected internal_encoding behavior is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100