Back to Content

TextEncoderStream

files/en-us/web/api/textencoderstream/index.md

latest1.5 KB
Original Source

{{APIRef("Encoding API")}}{{AvailableInWorkers}}

The TextEncoderStream interface of the {{domxref('Encoding API','','',' ')}} converts a stream of strings into bytes in the UTF-8 encoding. It is the streaming equivalent of {{domxref("TextEncoder")}}. It implements the same shape as a {{domxref("TransformStream")}}, allowing it to be used in {{domxref("ReadableStream.pipeThrough()")}} and similar methods.

Constructor

  • {{domxref("TextEncoderStream.TextEncoderStream","TextEncoderStream()")}}
    • : Creates a new TextEncoderStream object.

Instance properties

  • {{DOMxRef("TextEncoderStream.encoding")}} {{ReadOnlyInline}}
    • : Always returns "utf-8".
  • {{DOMxRef("TextEncoderStream.readable")}} {{ReadOnlyInline}}
    • : Returns the {{domxref("ReadableStream")}} instance controlled by this object.
  • {{DOMxRef("TextEncoderStream.writable")}} {{ReadOnlyInline}}
    • : Returns the {{domxref("WritableStream")}} instance controlled by this object.

Examples

Examples of streaming structured data and HTML

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also