encode

fun encode(input: String = definedExternally): Uint8Array<ArrayBuffer>(source)

The TextEncoder.encode() method takes a string as input, and returns a Global_Objects/Uint8Array containing the string character encoding using UTF-8.

MDN Reference