Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
@geraintluff

Description

Feature suggestion

I'd love a syntax like this:

let utf8Ptr = memory.data<u8>("Hello");
let utf16Ptr = memory.data<u16>("Hello");

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

let bytes = String.UTF8.byteLength(str, true);
let utf8Ptr = 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

        AltStyle によって変換されたページ (->オリジナル) /