Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Created June 17, 2018 18:32
Show Gist options
  • Save gskachkov/fb2757701d8745a69cfa31f533260374 to your computer and use it in GitHub Desktop.
Save gskachkov/fb2757701d8745a69cfa31f533260374 to your computer and use it in GitHub Desktop.
function utf8ToString(h, p) {
let s = "";
for (i = p; h[i]; i++) {
s += String.fromCharCode(h[i]);
}
return s;
}
let m = new WebAssembly.Instance(new WebAssembly.Module(buffer));
let h = new Uint8Array(m.exports.memory.buffer);
let p = m.exports.hello();
const value = utf8ToString(h, p);
console.log(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment