TextEncoder
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:1294
TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TextEncoder():
TextEncoder
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:1295
Returns
Section titled “Returns”TextEncoder
Properties
Section titled “Properties”encoding
Section titled “encoding”
readonly
encoding:string
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:1311
Methods
Section titled “Methods”encode()
Section titled “encode()”encode(
input?
):Uint8Array
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:1301
Returns the result of running UTF-8’s encoder.
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.20250823.0/node_modules/@cloudflare/workers-types/index.ts:1307
Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as an object wherein read is the number of converted code units of source and written is the number of bytes modified in destination.
Parameters
Section titled “Parameters”string
buffer
Section titled “buffer”ArrayBuffer
| ArrayBufferView
<ArrayBufferLike
>