Skip to content

Fix IO::Encoder#write when operating on long strings#16797

Open
jgaskins wants to merge 1 commit intocrystal-lang:masterfrom
jgaskins:fix-io-encoder-with-long-strings
Open

Fix IO::Encoder#write when operating on long strings#16797
jgaskins wants to merge 1 commit intocrystal-lang:masterfrom
jgaskins:fix-io-encoder-with-long-strings

Conversation

@jgaskins
Copy link
Copy Markdown
Contributor

This PR fixes encoding operations on long strings by ignoring Errno::E2BIG errors.

FWIW, this will need additional testing to ensure that strings with non-ASCII characters still work, but the test included with this PR fails without this patch and passes with it.

Fixes #16796

We accomplish this by ignoring `Errno::E2BIG` errors.
@crysbot
Copy link
Copy Markdown
Collaborator

crysbot commented Mar 30, 2026

This pull request has been mentioned on Crystal Forum. There might be relevant details there:

https://forum.crystal-lang.org/t/data-loss-when-writing-long-lines-with-file-print-after-file-set-encoding/8830/4

@ysbaddaden ysbaddaden added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:text labels Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data loss when writing long lines with File#print after File#set_encoding

3 participants