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 encoding of non-ascii strings #361

Merged
merged 2 commits into from
Jan 22, 2024
Merged

fix encoding of non-ascii strings #361

merged 2 commits into from
Jan 22, 2024

Conversation

jtbandes
Copy link
Member

Public-Facing Changes

Fixed a bug where non-ASCII strings would be truncated when MessageWriter encoded them as UTF-8.

Description

Fixes #360

str.length is the length of the string in UTF-16. However, we use TextEncoder to encode strings as UTF-8. We could compute the length using TextEncoder itself, but this proves to be much slower than a manual calculation: https://jsbench.me/nzlrkwmeiq/1

src/stringLengthUtf8.ts Show resolved Hide resolved
@jtbandes jtbandes merged commit c4c86df into main Jan 22, 2024
3 checks passed
@jtbandes jtbandes deleted the jacob/fg-6352-unicode branch January 22, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

MessageWritter gone wrong will using special character likes é,à,â,ô...
3 participants