WebAssembly / stringref

Other
37 stars 2 forks source link

`string.encode_wtf8`, `string.encode_wtf16` should return encoded length #24

Closed wingo closed 2 years ago

wingo commented 2 years ago

Currently string.encode_wtf8 and string.encode_wtf16 return nothing, effectively relying on the user to have computed a length via string.measure_wtf8 or string.measure_wtf16 beforehand. But they might as well return the encoded length; it's a value that's ready at hand, and there are some cases where you might reserve an ample buffer for encoding but you don't know how many bytes will be written.