-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Inline Web Worker looses special characters #12117
Comments
As MDN states, the A solution on StackOverflow might be this one: https://stackoverflow.com/a/43271130/7268229 function decodeBase64(base64) {
return new TextDecoder().decode(Uint8Array.from(atob(base64), c => c.charCodeAt(0)));
} |
I'm facing the same problem. How's it going? Thanks! @Simolation @sapphi-red |
@zhengcling You can help us by rebasing #12122 on main branch and adding a test for it. |
…15866) Signed-off-by: Jay Wang <[email protected]> Co-authored-by: 翠 / green <[email protected]>
Describe the bug
I am creating a TypeScript library using the Vite lib mode. When I use an inline Web Worker that has special characters in the code, those special characters are decoded incorrectly.
For example, I added a • character ( • ) into the Web Worker. When it is built and imported in another Vite project, the printed bullet character is â�¢ instead of • .
I observed that inside of the base64 encoded Web Worker in the build, the character is seemingly still correct, when I copy and paste the base64 text into https://www.base64decode.org/.
So, I suppose the problem is when loading and decoding the inline Web Worker using atob, as
atob("IOKAoiBIZWxsbyBmcm9tIHdvcmtlcg==")
isâ\x80¢ Hello from worker
.Reproduction
https://stackblitz.com/edit/vitejs-vite-tyt9yp
Steps to reproduce
Run
npm run install && npm run dev
in thevite-project
folder to start the package which imports the vite-lib. In the console log in the browser, the message the faulty message from the inline Web Worker is printed.System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: