Skip to content

Pre-initialised UTF string constants with memory.data<> #2972

Description

@geraintluff

Feature suggestion

I'd love a syntax like this:

letutf8Ptr=memory.data<u8>("Hello");letutf16Ptr=memory.data<u16>("Hello");

At the moment I'm doing this at runtime instead:

letbytes=String.UTF8.byteLength(str,true);letutf8Ptr=heap.alloc(bytes);String.UTF8.encodeUnsafe(changetype<usize>(str),str.length,utf8Ptr,true);

I could use String.UTF8.encode() instead, and then store the ArrayBuffer so it doesn't get GC'd, but as far as I can tell, that still ends up embedding the UTF-16 string in the output.

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