TextDecoder()
The TextDecoder()
constructor returns a newly created TextDecoder
object for the encoding specified in parameter.
Syntax
new TextDecoder()
new TextDecoder(label)
new TextDecoder(label, options)
Parameters
label
optional- : A string, defaulting to
"utf-8"
.
- : A string, defaulting to
options
optional: An object with the property:
fatal
- : A boolean value indicating if the
TextDecoder.decode()
method must throw aTypeError
when decoding invalid data. It defaults tofalse
, which means that the decoder will substitute malformed data with a replacement character.
- : A boolean value indicating if the
ignoreBOM
- : A boolean value indicating whether the byte order mark is ignored.
It defaults to
false
.
- : A boolean value indicating whether the byte order mark is ignored.
It defaults to
Exceptions
RangeError
- : Thrown if the value of
label
is unknown, or is one of the values leading to a'replacement'
decoding algorithm ("iso-2022-cn"
or"iso-2022-cn-ext"
).
- : Thrown if the value of