-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(TextEncoderStream): emoji encoding polyfill and add tests #6466
fix(TextEncoderStream): emoji encoding polyfill and add tests #6466
Conversation
👷 Deploy request for qwik-insights pending review.Visit the deploys page to approve it
|
@builder.io/qwik (
|
@octet-stream thanks a ton for looking into this and getting the test for it |
6f6f4b7
to
595fcb9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Looks good to me!
Thanks for adding tests 🙌
Yeah let's wait for e2e tests to pass before we merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help 👏🚀
Overview
Fixes #6458
What is it?
Description
The polyfill for TextEncoderStream introduced and proposed by me in #6310 (comment) for use in Bun and Cloudflare runtimes breaks emoji encoding. This PR fixes the encoding issue.
The issue caused by how I iterated over the input string: for...of loop relies on iterator protocol, which treats an emoji as a single character and iterates through it just once, and then
String.charCodeAt(0)
call was picking up just half of the symbol. Meanwhile, the Node.js' implementation iterates over the string using for loop which treats emojis as two symbols and then encodes each part of that symbol.Use cases and why
Expected: The encoder stream polyfill should handle emoji symbols correctly.
Actual: The encoder stream polyfill breaks emoji symbols.
Checklist: