files/en-us/web/api/textdecoder/encoding/index.md
{{APIRef("Encoding API")}}{{AvailableInWorkers}}
The TextDecoder.encoding read-only property returns a string containing the name of the character encoding that this decoder will use.
The encoding is set by the label parameter passed to the constructor, and defaults to utf-8.
A lower-cased ASCII string, which can be one of the following values:
'utf-8'.'x-user-defined'.'replacement'.
This decodes empty input into empty output and any other arbitrary-length input into a single replacement character.
It is used to prevent attacks that mismatch encodings between the client and server.
The following encodings also map to the replacement encoding: ISO-2022-CN, ISO-2022-CN-ext, 'iso-2022-kr', and 'hz-gb-2312'.{{Specifications}}
{{Compat}}