Interface

Gjsgjs/domTextEncoder

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

1.69.2

interface TextEncoder {
    encoding: "utf-8";
    encode(input?: string): Uint8Array;
    encodeInto(
        source: string,
        destination: Uint8Array,
    ): TextEncoderEncodeIntoResult;
}
Index

Properties

Methods

Properties

encoding: "utf-8"

Methods

  • Takes a string as input, and returns a buffer containing the text given in parameters encoded with the UTF-8 method.

    Parameters

    • Optionalinput: string

      Text to encode.

    Returns Uint8Array

  • Takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding.

    This is potentially more performant than the older encode() method.

    Parameters

    • source: string

      Text to encode.

    • destination: Uint8Array

      Buffer where to place the resulting UTF-8 encoded text into.

    Returns TextEncoderEncodeIntoResult