ethereumjs-monorepo

@ethereumjs/util


@ethereumjs/util / utf8ToBytes

Function: utf8ToBytes()

utf8ToBytes(str): Uint8Array

Defined in: packages/util/node_modules/@noble/hashes/utils.d.ts:64

Converts string to bytes using UTF8 encoding. Built-in doesn’t validate input to be string: we do the check.

Parameters

str

string

Returns

Uint8Array

Example

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