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

Fix UTF8 sequences being split #74

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Fix UTF8 sequences being split #74

merged 1 commit into from
Aug 9, 2023

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Aug 9, 2023

This PR fixes the following bug: when a binary stream is converted to a string using getStream(), if it contains UTF8 multibyte sequences which are split in-between multiple chunks, this results in a broken output.

This PR addresses this by using new TextDecoder() in stream mode.
Note: this is also how core Node.js implements this in the node:stream/consumers text() method.
https://github.com/nodejs/node/blob/6432060c7ce1670467c230d2c0c925465dd311f8/lib/stream/consumers.js#L57-L70

@sindresorhus
Copy link
Owner

Conflict

@ehmicky
Copy link
Collaborator Author

ehmicky commented Aug 9, 2023

Fixed 👍

@sindresorhus sindresorhus merged commit 730d83f into sindresorhus:main Aug 9, 2023
3 checks passed
@ehmicky ehmicky deleted the fix-utf8-sequences branch August 9, 2023 00:16
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.

2 participants