Encoding API

Encoding API 提供了一种机制来处理各种字符编码文本,包括传统的非 UTF-8 编码。

API 提供了四个接口:TextDecoderTextEncoderTextDecoderStreamTextEncoderStream

备注: 此特性在 Web Worker 中可用。

接口

规范

Specification
Encoding
# interface-textdecoder
Encoding
# interface-textencoder
Encoding
# interface-textencoderstream
Encoding
# interface-textdecoderstream

浏览器兼容性

api.TextDecoder

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
TextDecoder
TextDecoder() constructor
decode
encoding
fatal
ignoreBOM
Available in workers

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
See implementation notes.
Has more compatibility info.

api.TextEncoder

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
TextEncoder
TextEncoder() constructor
encode
encodeInto
encoding
Available in workers

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

api.TextEncoderStream

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
TextEncoderStream
TextEncoderStream() constructor
encoding
readable
writable

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

api.TextDecoderStream

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
TextDecoderStream
TextDecoderStream() constructor
encoding
fatal
ignoreBOM
readable
writable

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

参见

  • 一个 shim,允许在不支持的浏览器中使用这个接口。