Encode a UTF-8 string into a Uint8Array.
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.
TextEncoder
string to encode
On wrong argument types. TypeError
Encode a string as UTF-8 bytes.
utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99]) Copy
utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])
Encode a UTF-8 string into a
Uint8Array.Param: str
The string to encode.
Returns
UTF-8 encoded bytes.