interface TextDecoder
extends TextDecoderCommon
Represents a decoder for a specific text encoding, allowing you to convert binary data into a string given the encoding.
Examples Jump to heading
Jump to heading
Example 1
Example 1
const decoder = new TextDecoder('utf-8');
const buffer = new Uint8Array([72, 101, 108, 108, 111]);
const decodedString = decoder.decode(buffer);
console.log(decodedString); // Outputs: "Hello"
Methods Jump to heading
Jump to headingdecode(input?: BufferSource,options?: TextDecodeOptions,): string
Turns binary data, often in the form of a Uint8Array, into a string given the encoding.