Stream: git-wasmtime

Topic: wasmtime / issue #6719 Unable to get the string_encoding ...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2023 at 11:10):

GordonSmith opened issue #6719:

Feature

I am trying to implement the "load_string_from_range" ABI function in c++:

def load_string_from_range(cx, ptr, tagged_code_units):
  match cx.opts.string_encoding:
    case 'utf8':
...
    case 'utf16':
...
    case 'latin1+utf16':
...

  return (s, cx.opts.string_encoding, tagged_code_units)

But have been unable to locate anything relating to cx.opts.string_encoding in the c/c++ headers

Benefit

Avoid potential issues dealing with strings

Implementation

Alternatives

Assume string type is "utf8"?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2023 at 13:52):

alexcrichton commented on issue #6719:

Thanks for the report, but the component model is not supported in the C API yet. So in that sense it's expected that the string encoding isn't availble.

It's worth pointing out though that this string encoding isn't even available in the Rust API, though. This is an internal implementation detail of components which embedders shouldn't in theory need to know about (other than optimizing perhaps)

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2023 at 14:16):

GordonSmith commented on issue #6719:

Thanks for the update - also if the "tagged_code_units" is meant to represent the string length (and not the buffer length - then the python utf8 case looks wrong to my eye (or is that a question for the spec repo)?

Ref: https://github.com/WebAssembly/component-model/blob/main/design/mvp/canonical-abi/definitions.py#L448C1-L474C57

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2023 at 14:16):

GordonSmith edited a comment on issue #6719:

Thanks for the update - also if the "tagged_code_units" is meant to represent the string length (and not the buffer length) - then the python utf8 case looks wrong to my eye (or is that a question for the spec repo)?

Ref: https://github.com/WebAssembly/component-model/blob/main/design/mvp/canonical-abi/definitions.py#L448C1-L474C57

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2023 at 15:33):

alexcrichton commented on issue #6719:

I think that's a question/issue for the spec repo

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2023 at 16:24):

GordonSmith commented on issue #6719:

Thx... closing.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2023 at 16:24):

GordonSmith closed issue #6719:

Feature

I am trying to implement the "load_string_from_range" ABI function in c++:

def load_string_from_range(cx, ptr, tagged_code_units):
  match cx.opts.string_encoding:
    case 'utf8':
...
    case 'utf16':
...
    case 'latin1+utf16':
...

  return (s, cx.opts.string_encoding, tagged_code_units)

But have been unable to locate anything relating to cx.opts.string_encoding in the c/c++ headers

Benefit

Avoid potential issues dealing with strings

Implementation

Alternatives

Assume string type is "utf8"?


Last updated: Dec 23 2024 at 12:05 UTC