Skip to content

The ascii generated when the function returns a string type is incorrect #2847

@996ccs

Description

@996ccs

Question

I wrote a function getA using AssemblyScript to return an A string. After compilation, I got a wasm file. Then I used other wasm runtime to parse the wasm file and called the getA function hoping to get the ascii value 65 corresponding to A. But what I got was [2, 0, 0, 0, 2, 0, 0, 0, 65] The wat file compiled by AssemblyScript is as follows

(module
 (type $0 (func (result i32)))
 (memory $0 1)
 (data $0 (i32.const 1036) "\1c")
 (data $0.1 (i32.const 1048) "\02\00\00\00\02\00\00\00A")
 (export "getA" (func $assembly/index/getA))
 (export "memory" (memory $0))
 (func $assembly/index/getA (result i32)
  i32.const 1056
 )
)

Judging from the compiled product above, the prefix '\02\00\00\00\02\00\00\00' is obviously redundant.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions