JavaScripture
Contribute via GitHub Feedback

TextDecoder : Object

Decodes sequences of bytes into Strings.

Constructors

new TextDecoder() : TextDecoder

Constructs a new TextDecoder that decodes UTF-8 strings.

Example:

Run

Results:

 

new TextDecoder(label : String, [options : Object]) : TextDecoder
options : {
fatal :Boolean
ignoreBOM :Boolean
}

Constructs a new TextDecoder. See https://encoding.spec.whatwg.org/#concept-encoding-get for valid label values.

Example:

Run

Results:

 

Instance Properties

encoding : String  

Returns the effective encoding from the label specified during construction of this. See https://encoding.spec.whatwg.org/#concept-encoding-get for the mapping from label values to encodings.

Example:

Run

Results:

 

fatal : Boolean  

Example:

Run

Results:

 

ignoreBOM : Boolean  

Example:

Run

Results:

 

Instance Methods

decode 2 variants
decode(input : ArrayBufferView, [options : Object]) : String
options : {
stream :Boolean
}

Decodes the bytes from input into a new String based on this.encoding. If options.stream is true, this will remember any partially consumed characters and apply them to the next decode() call.

Example:

Run

Results:

 

decode(input : ArrayBuffer, [options : Object]) : String
options : {
stream :Boolean
}

Decodes the bytes from input into a new String based on this.encoding. If options.stream is true, this will remember any partially consumed characters and apply them to the next decode() call.

Example:

Run

Results: