Repository navigation
IO: add external_encoding, internal_encoding and set_encoding - #478
Merged
Merged
Conversation
IO streams now carry an external/internal encoding pair (new IOObj.extEnc / intEnc fields): - external_encoding returns the explicitly-set encoding, else Encoding .default_external — except a write-only stream with no encoding and no default internal encoding, which reports nil, as MRI does. - internal_encoding returns the set internal encoding, or nil. - set_encoding(ext, int = nil) accepts an Encoding, an encoding name, or a combined "external:internal" string (a nil argument clears that side) and returns self; an unknown name raises ArgumentError and a non-String/Encoding argument a TypeError. Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec floor rises 15905 -> 16080 (core/io external_encoding 0->59, internal_encoding 0->79, set_encoding 0->21). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IO streams now carry an external/internal encoding pair (new
IOObj.extEnc/intEncfields) — the first step of the encoding subsystem:external_encodingreturns the explicitly-set encoding, elseEncoding.default_external— except a write-only stream with no encoding andno default internal encoding, which reports
nil, as MRI does.internal_encodingreturns the set internal encoding, ornil.set_encoding(ext, int = nil)accepts anEncoding, an encoding name, or acombined
"external:internal"string (anilargument clears that side) andreturns self; an unknown name raises
ArgumentError, a non-String/Encodingargument a
TypeError.Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
ratchet floor rises 15905 → 16080 (
core/ioexternal_encoding 0→59,internal_encoding 0→79, set_encoding 0→21, +166 aggregate, zero regressions in a
deterministic per-file sweep).
🤖 Generated with Claude Code