Stream: general

Topic: Read string from AssemblyScript wasm module


view this post on Zulip Ari Seyhun (Sep 19 2022 at 11:59):

I'm trying to read a string from an assemblyscript wasm module.

I've loaded the module sucessfully, and tried calling console.log. console.log provides one argument: u32, which is an offset to where the string is stored in memory, though my problem is that I don't know the length of this string, which is required for the memory.read(...) method.
I was thinking I might need something like read_until, but I'm not sure exactly.

Any ideas on how I can read a full string from an AssemblyScript compiled module from wasmtime Rust?

view this post on Zulip Peter Huene (Sep 19 2022 at 19:42):

According to https://www.assemblyscript.org/runtime.html#memory-layout, strings have their length encoded in the rtSize member of the header that is at offset -4 from the string's data pointer, which is in bytes and not UTF-16 (or perhaps WTF-16?) code units.


Last updated: Nov 22 2024 at 16:03 UTC