Re: [whatwg/encoding] TextEncoder#encode - write to existing Uint8Array (#69)

@domenic Sorry, I should have made it clear. _offset_ is an offset into the string, not into the view. It would be inefficient for callers to chop the front of the string after every call, so instead we include the ability to ignore _offset_ code units.

Argument summary:
_view_: a BufferSource to accept the output of the conversion
_string_: A USVString to be converted
_offset_: The number of code units at the start of _string_ to ignore.

Return value is the index into the string which the encoder reached (but it might be better to return the number of code units consumed?). If the entire string was converted, the return value will be equal to string.length.

If the output buffer is less than 4 bytes long, it is possible for examples like I wrote above to loop forever. Maybe encodeInto() should throw if it can't make progress?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/issues/69#issuecomment-434175905

Received on Tuesday, 30 October 2018 05:22:52 UTC