@kayahr/text-encoding
Version:
Text encoder and decoder
30 lines (29 loc) • 1.11 kB
TypeScript
/**
* The TextDecoder represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, KOI8-R, GBK, etc.
* A decoder takes a stream of bytes as input and emits a stream of code points.
*/
export declare class TextDecoder implements globalThis.TextDecoder {
/** True if byte order marker is ignored. */
readonly ignoreBOM: boolean;
/** True if error mode is fatal. */
readonly fatal: boolean;
private readonly enc;
private seenBOM;
private decoder;
/**
* Creates text decoder for the given encoding.
*
* @param label - The label of the encoding. Defaults to 'utf-8'
*/
constructor(label?: string, { fatal, ignoreBOM }?: TextDecoderOptions);
/** @returns The name of the encoding. */
get encoding(): string;
/**
* Decoded the given input into string and returns it.
*
* @param input - The input to decode.
* @param options - The decoding options.
* @returns The decoded string.
*/
decode(input?: BufferSource | ArrayBufferLike | ArrayBufferView, { stream }?: TextDecodeOptions): string;
}