Re: [whatwg/encoding] What's the correct use of {stream: true} option for Textdecoder.decode (#184)

The `stream` option changes the handling of the end of the input to allow it to be in the middle of a character. Compare:
```javascript
decoder.decode(new Uint8Array([226, 153]), { stream: true });
// ""
decoder.decode(new Uint8Array([165]), { stream: true });
// "♥"
```
to
```javascript
decoder.decode(new Uint8Array([226, 153]));
// "��"
decoder.decode(new Uint8Array([165]));
// "�"
```
Even with `{stream: true}` the TextDecoder emits all complete characters as soon as possible.

You may find [TextDecoderStream](https://encoding.spec.whatwg.org/#interface-textdecoderstream) a more intuitive way to do the same thing.

-- 
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/184#issuecomment-527733881

Received on Wednesday, 4 September 2019 04:25:04 UTC