GitHub iconEdit on GitHub



The TextEncoder takes a stream of code points as input and emits a stream of bytes. Encoding types passed to the constructor are ignored and a UTF-8 TextEncoder is created.


TextEncoder() returns a newly constructed TextEncoder that generates a byte stream with UTF-8 encoding. TextEncoder takes no parameters and throws no exceptions.


encoding (Read only) this DOMString contains the name of the encoder as a string describing the method the TextEncoder uses (always utf-8).


encode() takes a USVString as input and returns a Uint8Array with UTF-8 encoded text.


The TextDecoder interface represents a UTF-8 decoder. Decoders take a stream of bytes as input and emit a stream of code points.


TextDecoder() returns a newly constructed TextDecoder that generates a code-point stream.


  • encoding(Read only) is a DOMString with the name of the decoder that describes the method the TextDecoder uses.

  • TextDecoder.fatal (Read only) is a Boolean value to indicate if the error mode is fatal.

  • TextDecoder.ignoreBOM (Read only) is a Boolean value to indicate if the byte-order marker is ignored.


decode() returns a DOMString that contains the text decoded using the method specified in the TextDecoder object.