An implementation of the WHATWG Encoding Standard TextEncoder API. All instances of TextEncoder only support UTF-8 encoding.

TextEncoder takes a stream of code points as input and emits a stream of UTF-8 bytes.

See

TextEncoder on MDN

Example

const encoder = new TextEncoder();
const uint8array = encoder.encode('a string to encode');

Hierarchy

  • TextEncoder

Constructors

Properties

Methods

Constructors

Properties

encoding: "utf-8"

The TextEncoder.encoding read-only property returns a string containing the name of the encoding algorithm used by the specific encoder. It is always set to the value "utf-8".

Methods

  • UTF-8 encodes the input string and returns a Uint8Array containing the encoded bytes.

    Parameters

    • Optional input: string

    Returns Uint8Array

Generated using TypeDoc