Polkadot Apps
    Preparing search index...

    Encode a UTF-8 string into a Uint8Array.

    The string to encode.

    UTF-8 encoded bytes.

    • Converts string to bytes using UTF8 encoding. Built-in doesn't validate input to be string: we do the check. Non-ASCII details are delegated to the platform TextEncoder.

      Parameters

      • str: string

        string to encode

      Returns Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>

      UTF-8 encoded bytes.

      On wrong argument types. TypeError

      Encode a string as UTF-8 bytes.

      utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])