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 text given in parameters encoded with the specific method for that TextEncoder object.

MDN Reference