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 JS UTF16 #371

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/js/lib/api/diplomat-runtime.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions feature_tests/js/api/diplomat-runtime.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tool/src/js/runtime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function readString8(wasm, ptr, len) {

export function readString16(wasm, ptr, len) {
const buf = new Uint16Array(wasm.memory.buffer, ptr, len);
return String.fromCharCode(buf)
return String.fromCharCode.apply(null, buf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, I noticed this earlier and figured this was just some functionality of .fromCharCode I didn't know, JS has a lot of these helpers. Should have left a comment.

Anyway, this works

}

export function withWriteable(wasm, callback) {
Expand Down Expand Up @@ -89,7 +89,7 @@ export class DiplomatBuf {
static str16 = (wasm, string) => {
return new DiplomatBuf(wasm, string.length, 2, buf => {
for (var i; i < string.length; i++) {
buf[i] = string.codePointAt(i);
buf[i] = string.charCodeAt(i);
}
})
}
Expand Down
Loading