TextEncoder
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1484
The TextEncoder interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TextEncoder():
TextEncoder
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1485
Returns
Section titled “Returns”TextEncoder
Properties
Section titled “Properties”encoding
Section titled “encoding”
readonlyencoding:string
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1498
Methods
Section titled “Methods”encode()
Section titled “encode()”encode(
input?):Uint8Array
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1491
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.
Parameters
Section titled “Parameters”input?
Section titled “input?”string
Returns
Section titled “Returns”Uint8Array
encodeInto()
Section titled “encodeInto()”encodeInto(
input,buffer):TextEncoderEncodeIntoResult
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1497
The TextEncoder.encodeInto() method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding.
Parameters
Section titled “Parameters”string
buffer
Section titled “buffer”Uint8Array