-
Notifications
You must be signed in to change notification settings - Fork 60.6k
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 [Utils] Replace Text Encoder #4093
Conversation
@Rolaka is attempting to deploy a commit to the NextChat Team on Vercel. A member of the Team first needs to authorize it. |
Your build has completed! |
that's one might break other language |
We don't need to discuss this issue from a particular language point of view, but only from the point of view of how to encode characters correctly. First, there are two errors in the old code:
Secondly, if you want to discuss the range of corrupted characters, see this Link , from the third row of the table onwards it's all in the wrong range. Finally, why TextEncoder? Because it is a function in the Specification. Details: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder We can find many examples for file output on Github |
Maybe you don't realize the seriousness of this problem, I would like to show you more relevant information to show where the old code is wrong. Let's refer to the description of ecma256. https://262.ecma-international.org/14.0/#sec-terms-and-definitions-string-value
https://262.ecma-international.org/14.0/#sec-ecmascript-language-types-string-type
As you can see above, in JavaScript, each character is stored using Uint16, not Uint8, unlike other, more primitive languages. So the old code uses Uint8 in the conversion process, resulting in the loss of two bytes of data. So it's simple for us to verify this with a snippet of code, although it seems pointless.
This question is only about coding, not about language, I hope I explained it clearly enough. 2.10.3 changed the package name so that tauri was unable to find data stored in localstorage in webkit from versions before to 2.10.2, and the "Export" supply was broken for 5 months due to a bug in the old code. Of course, that's just my suspicion. "Export" is the most convenient method of data transfer, and fixing it as soon as possible is necessary. |
@fred-bf I'm sorry to bother you, but this serious low-level issue hasn't been resolved for 5 months. Could you consider fixing this bug as soon as possible? Thank you for your time. |
Many thanks to the maintainers for finally fixing this bug, the export feature is a very important thing for many people. This pr is obsolete and could be closed. |
[+] fix(utils.ts): replace text encoder
Use a better way of encoding text, the current code is wrong.
Replacing old code with TextEncoder.