Encoding
What is Encoding API
Mechanism for handling text in various character encodings, including legacy non-UTF-8 encodings.
The API provides four interfaces: TextDecoder, TextEncoder, TextDecoderStream and TextEncoderStream.
TextDecoderStream
Streaming equivalent of TextDecoder
.
- converts a stream of text in a binary encoding, such as UTF-8 etc., to a stream of strings.
const response = await fetch("https://example.com"); const stream = response.body.pipeThrough(new TextDecoderStream());