
Code
A Quick Tour of the Web Encoding API
Modern web apps live at the boundary between JavaScript strings and raw bytes. The Web Encoding API exists to make that boundary explicit and safe: it lets you encode a string into UTF‑8 bytes and decode bytes back into text. Importantly, these operations aren’t symmetrical—encoding targets UTF‑8, while decoding can interpret UTF‑8 and many legacy encodings. Alongside the synchronous TextEncoder and TextDecoder, the platform also provides stream-based variants for processing text incrementally as data arrives.
