Encoding

Encoding Standard (subset)

Module: whatwg.encoding Support: Experimental Since: 1.1.0 Docs: WHATWG Docs

Dictionary TextDecoderOptions

Since: 1.1.0 Docs: WHATWG Docs

2 members: 2 undocumented

Properties

⚪ fatal
If true, decoding errors cause an exception rather than replacement characters.
⚪ ignoreBOM
If true, the BOM is not stripped from the start of the decoded string.

---

Dictionary TextDecodeOptions

Since: 1.1.0 Docs: WHATWG Docs

1 members: 1 undocumented

Properties

⚪ stream
If true, decodes incrementally, holding back incomplete sequences for the next call.

---

Interface TextDecoder

Decodes a binary buffer into a string using a specified character encoding.

Since: 1.1.0 Docs: WHATWG Docs

5 members: 5 undocumented

Constructors

⚪ constructor(label, options)
string, TextDecoderOptions

Methods

⚪ decode(input, options)
→ string

Properties

⚪ encoding
→ string
⚪ fatal
If true, decoding errors cause an exception rather than replacement characters.
⚪ ignoreBOM
If true, the BOM is not stripped from the start of the decoded string.

---

Details

constructor(label, options)

new constructor(label?: string, options?: TextDecoderOptions) new constructor(label?: string, options?: TextDecoderOptions)
ParameterTypeDescription
label (optional)stringThe encoding label (e.g. "utf-8", "utf-16le"). Defaults to "utf-8".
options (optional)TextDecoderOptionsDecoder options controlling error handling and BOM behavior.
Throws:
  • RangeError --- If label is not a valid encoding label.

encoding

encoding: string

encoding: string

Throws:
  • RangeError --- If label is not a valid encoding label.

decode(input, options)

decode(input?: BufferSource, options?: TextDecodeOptions): string decode(input?: BufferSource, options?: TextDecodeOptions): string
ParameterTypeDescription
input (optional)BufferSourceThe buffer to decode.
options (optional)TextDecodeOptionsOptions for streaming decode.
Returns: string The decoded string. Throws:
  • TypeError --- If fatal is true and the input contains invalid sequences.

---

Interface TextEncoder

Encodes a string into a UTF-8 byte sequence.

Since: 1.1.0 Docs: WHATWG Docs

4 members: 4 undocumented

Constructors

⚪ constructor()
Not documented

Methods

⚪ encode(input)
→ BufferSource
⚪ encodeInto(source, destination)
Encodes `source` into `destination` without allocating a new buffer.

Properties

⚪ encoding
→ string

---

Details

constructor()

new constructor()

new constructor()

Throws:
  • RangeError --- If label is not a valid encoding label.

encoding

encoding: string

encoding: string

Throws:
  • RangeError --- If label is not a valid encoding label.

---

Dictionary TextEncoderEncodeIntoResult

Encodes source into destination without allocating a new buffer.

2 members: 2 undocumented

Properties

⚪ read
Result returned by TextEncoder.encodeInto().
⚪ written
The number of UTF-16 code units read from the source string.

---