Skip to content

Keep the encoding of GzipReader#read at EOF - #189

Open
hsbt wants to merge 2 commits into
masterfrom
claude/stoic-mahavira-34a5d3
Open

hsbt wants to merge 2 commits into
masterfrom
claude/stoic-mahavira-34a5d3

Conversation

@hsbt

@hsbt hsbt commented Nov 10, 2026

Copy link
Copy Markdown
Member

GzipReader#read without a length returns a binary empty string at EOF, while the earlier calls return strings in the read encoding. IO#read keeps the read encoding at EOF too.

gz = Zlib::GzipReader.new(StringIO.new(Zlib.gzip("x")))
gz.read.encoding #=> #<Encoding:UTF-8>
gz.read.encoding
# expected: #<Encoding:UTF-8>
# actual:   #<Encoding:BINARY (ASCII-8BIT)>

Generated with Claude Code

hsbt and others added 2 commits October 25, 2026 09:25
Without a length, GzipReader#read returned a binary empty string once all data had been read, while the earlier calls return strings in the read encoding. IO#read keeps the read encoding at EOF too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With Encoding.default_internal set, as under ruby -U, GzipReader converts to it and the read encoding is not EUC-JP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

1 participant