Skip to main content
TextEncoder.prototype.encodeInto - node__util.d.ts - Node documentation
method TextEncoder.prototype.encodeInto

Usage in Deno

```typescript import { TextEncoder } from "node:node__util.d.ts"; ```
TextEncoder.prototype.encodeInto(
src: string,
dest: Uint8Array,
): EncodeIntoResult
UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object containing the read Unicode code units and written UTF-8 bytes. ```js const encoder = new TextEncoder(); const src = 'this is some data'; const dest = new Uint8Array(10); const { read, written } = encoder.encodeInto(src, dest); ```

Parameters

src: string
The text to encode.
dest: Uint8Array
The array to hold the encode result.

Return Type