class TextEncoder

Supported only in the v8 engine. Introduced in Max v9.2.0.

Encodes JavaScript strings into UTF-8 bytes.

Only UTF-8 is supported.

Example

const bytes = new TextEncoder().encode("hello");
post(bytes.length, "\n"); // 5

Index

Constructors

Properties

Methods

new TextEncoder()

new TextEncoder();

Constructs a new instance of the TextEncoder class

encode(input)

Encodes a string into UTF-8 bytes.

encode(input?: string): buffer.IOBuffer;
NameTypeDescription
optional inputstringthe string to encode (default "")
Return Valuebuffer.IOBufferthe encoded bytes as an buffer.IOBuffer (a Uint8Array subclass)

encoding string read-only

Always "utf-8".