TextDecoder.encoding
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
只读属性 TextDecoder.encoding
返回一个字符串,其中包含了指定的解码器的解码算法的名称。
编码由构造函数的 label
参数设置,并且默认是 utf-8
。
值
小写的 ASCII 字符,可以是以下值之一:
- Web 推荐的编码:
'utf-8'
。 - 传统的单字节编码:
'ibm866'
、'iso-8859-2'
、'iso-8859-3'
、'iso-8859-4'
、'iso-8859-5'
、'iso-8859-6'
、'iso-8859-7'
、'iso-8859-8'
、'iso-8859-8i'
、'iso-8859-10'
、'iso-8859-13'
、'iso-8859-14'
、'iso-8859-15'
、'iso-8859-16'
、'koi8-r'
、'koi8-u'
、'macintosh'
、'windows-874'
、'windows-1250'
、'windows-1251'
、'windows-1252'
、'windows-1253'
、'windows-1254'
、'windows-1255'
、'windows-1256'
、'windows-1257'
、'windows-1258'
或'x-mac-cyrillic'
。 - 传统的多字节中文(简体)编码:
'gbk'
、'gb18030'
和'hz-gb-2312'
。 - 传统的多字节中文(繁体)编码:
'big5'
。 - 传统的多字节日语编码:
'euc-jp'
、'iso-2022-jp'
和'shift-jis'
。 - 传统的多字节韩语编码:
'euc-kr'
和'iso-2022-kr'
。 - 传统的其他编码:
'utf-16be'
、'utf-16le'
和'x-user-defined'
。 - 一种特殊的编码,
'replacement'
,它只会发出一个错误和一个EOF
代码点。它用于阻止客户端和服务端之间编码不匹配的攻击。ISO-2022-CN
和ISO-2022-CN-ext
可能发生这种情况。
规范
Specification |
---|
Encoding # ref-for-dom-textdecoder-encoding① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
encoding |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
- 属于
TextDecoder
接口。