다음을 통해 공유


TextDecoder class

WHATWG 인코딩 표준TextDecoder API의 구현입니다.

const decoder = new TextDecoder();
const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
console.log(decoder.decode(u8arr)); // Hello

생성자

TextDecoder(string, { fatal?: boolean, ignoreBOM?: boolean })

속성

encoding

TextDecoder 인스턴스에서 지원하는 인코딩입니다.

fatal

디코딩 오류로 인해 TypeError throw되는 경우 값이 true.

ignoreBOM

디코딩 결과에 바이트 순서 표시가 포함되면 값이 true.

메서드

decode(null | ArrayBuffer | ArrayBufferView, { stream?: boolean })

input 디코딩하고 문자열을 반환합니다. options.stream true경우 input 끝에서 발생하는 불완전한 바이트 시퀀스는 내부적으로 버퍼링되고 textDecoder.decode()다음 호출 후에 내보내집니다.

textDecoder.fatal true경우 발생하는 오류를 디코딩하면 TypeError throw됩니다.

생성자 세부 정보

TextDecoder(string, { fatal?: boolean, ignoreBOM?: boolean })

new TextDecoder(encoding?: string, options?: { fatal?: boolean, ignoreBOM?: boolean })

매개 변수

encoding

string

options

{ fatal?: boolean, ignoreBOM?: boolean }

속성 세부 정보

encoding

TextDecoder 인스턴스에서 지원하는 인코딩입니다.

encoding: string

속성 값

string

fatal

디코딩 오류로 인해 TypeError throw되는 경우 값이 true.

fatal: boolean

속성 값

boolean

ignoreBOM

디코딩 결과에 바이트 순서 표시가 포함되면 값이 true.

ignoreBOM: boolean

속성 값

boolean

메서드 세부 정보

decode(null | ArrayBuffer | ArrayBufferView, { stream?: boolean })

input 디코딩하고 문자열을 반환합니다. options.stream true경우 input 끝에서 발생하는 불완전한 바이트 시퀀스는 내부적으로 버퍼링되고 textDecoder.decode()다음 호출 후에 내보내집니다.

textDecoder.fatal true경우 발생하는 오류를 디코딩하면 TypeError throw됩니다.

function decode(input?: null | ArrayBuffer | ArrayBufferView, options?: { stream?: boolean }): string

매개 변수

input

null | ArrayBuffer | ArrayBufferView

인코딩된 데이터를 포함하는 ArrayBuffer, DataView또는 TypedArray 인스턴스입니다.

options

{ stream?: boolean }

반환

string