Preparing search index...

    Encodes strings into UTF-8 byte arrays.

        // Encode a string to UTF-8 bytes with TextEncoder
    const encoder = new TextEncoder();
    const encoded = encoder.encode('Hello World');
    console.log('Encoded bytes length:', encoded.length);
    console.log('Encoder encoding:', encoder.encoding);

    // Decode bytes back to string with TextDecoder
    const decoder = new TextDecoder();
    const decoded = decoder.decode(encoded);
    console.log('Decoded string:', decoded);
    console.log('Decoder encoding:', decoder.encoding);

    // Verify round-trip: encode then decode produces the original string
    const original = 'Lens Studio Editor API';
    const roundTrip = new TextDecoder().decode(new TextEncoder().encode(original));
    console.log('Round-trip match:', original === roundTrip);

    // encodeInto writes directly into an existing Uint8Array
    const buffer = new Uint8Array(32);
    encoder.encodeInto('Test', buffer);
    console.log('encodeInto first byte (T = 84):', buffer[0]);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    encoding: string

    The encoding format used by this encoder, always 'utf-8'.

    Methods

    • Encodes a string into a Uint8Array using UTF-8.

      Parameters

      • value: string

      Returns Uint8Array

    • Encodes a string into an existing Uint8Array in place.

      Parameters

      • value: string
      • result: Uint8Array

      Returns void

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean