mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-10 17:12:41 +02:00
This is the streaming counterpart to TextDecoder, used by sites that process responses with `pipeThrough(new TextDecoderStream())` or that otherwise consume a Response body as decoded text. The transform algorithm appends each chunk's bytes to the I/O queue and decodes them via the underlying LibTextCodec decoder, holding back any trailing partial UTF-8 sequence so chunk boundaries don't produce spurious replacement characters. The flush algorithm emits a single replacement character if a partial sequence was still pending. For non-UTF-8 encodings the underlying decoders are stateless across calls, so each chunk is decoded in full with nothing carried over.