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

GzipReader: internal_encoding option overwrites external_encoding #81

Open
olofheurgren opened this issue May 28, 2024 · 0 comments
Open

Comments

@olofheurgren
Copy link

olofheurgren commented May 28, 2024

(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

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

No branches or pull requests

1 participant