You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/js-string-builtins/Overview.md
+17-17
Original file line number
Diff line number
Diff line change
@@ -157,14 +157,6 @@ For this purpose, `WebAssembly.validate()` is extended to take a list of builtin
157
157
158
158
If a user wishes to polyfill these imports for some reason, or is running on a system without a builtin, these imports may be provided as normal through instantiation.
159
159
160
-
## UTF8/WTF8 support
161
-
162
-
As stated above in 'goals for builtins', builtins are intended to just wrap existing primitives and not invent new functionality.
163
-
164
-
JS Strings are semantically a sequence of 16-bit code units (referred to as char codes in method naming), and there are no builtin operations on them to acquire a UTF-8 or WTF-8 view. This makes it difficult to write Wasm builtins for these encodings without introducing significant new logic to them.
165
-
166
-
There is the Encoding API for `TextEncoder`/`TextDecoder` which can be used for UTF-8 support. However, this is technically a separate spec from JS and may not be available on all JS engines (in practice it's available widely). This proposal exposes UTF-8 data conversions using this API under separate `wasm:text-encoder``wasm:text-decoder` interfaces which are available when the host implements these interfaces.
167
-
168
160
## String constants
169
161
170
162
String constants may be defined in JS and made available to Wasm through a variety of means.
@@ -551,7 +543,19 @@ function compare(
551
543
}
552
544
```
553
545
554
-
## Encoding API
546
+
## Future extensions
547
+
548
+
There are several extensions we can make in the future as need arrives.
549
+
550
+
### UTF8/WTF8 support
551
+
552
+
As stated above in 'goals for builtins', builtins are intended to just wrap existing primitives and not invent new functionality.
553
+
554
+
JS Strings are semantically a sequence of 16-bit code units (referred to as char codes in method naming), and there are no builtin operations on them to acquire a UTF-8 or WTF-8 view. This makes it difficult to write Wasm builtins for these encodings without introducing significant new logic to them.
555
+
556
+
There is the Encoding API for `TextEncoder`/`TextDecoder` which can be used for UTF-8 support. However, this is technically a separate spec from JS and may not be available on all JS engines (in practice it's available widely). This proposal exposes UTF-8 data conversions using this API under separate `wasm:text-encoder``wasm:text-decoder` interfaces which are available when the host implements these interfaces.
557
+
558
+
### Encoding API
555
559
556
560
The following is an initial set of function builtins for the [`TextEncoder`](https://encoding.spec.whatwg.org/#interface-textencoder) and the [`TextDecoder`](https://encoding.spec.whatwg.org/#interface-textdecoder) interfaces. These builtins are exposed under `wasm:text-encoder` and `wasm:text-decoder`, respectively.
There are several extensions we can make in the future as need arrives.
766
-
767
767
### Binding memory to builtins
768
768
769
769
It may be useful to have a builtin that operates on a specific Wasm memory. For JS strings, this could allow us to encode a JS string directly into linear memory.
0 commit comments