TextDecoderStream: encoding property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2022.
Note: This feature is available inWeb Workers.
Theencoding
read-only property of theTextDecoderStream
interface returns a string containing the name of the encoding algorithm used by the specific decoder.
The encoding is set by theconstructorlabel
parameter, and defaults toutf-8
.
In this article
Value
A string containing the lower-cased ASCII name of the encoding format.
The allowed values are the same as those listed inTextDecoder.encoding
(the labels inEncoding API Encodings).
Examples
Returning the value ofencoding
from aTextDecoderStream
.
js
stream = new TextDecoderStream();console.log(stream.encoding); // returns the default "utf-8"
Specifications
Specification |
---|
Encoding> # dom-textdecoder-encoding> |
Browser compatibility
Loading…