The TextEncoder()
constructor returns a newly created utf-8 TextEncoder
object.
Syntax
encoder = new TextEncoder();
Parameters
TextEncoder()
takes no parameters since Firefox 48 and Chrome 53
Note: Prior to Firefox 48 and Chrome 53, an encoding type label was accepted as a paramer to the TextEncoder
object, since then both browers have removed support for any encoder type other than utf-8
, to match the spec. Any type label passed into the TextEncoder
constructor will now be ignored and a utf-8
TextEncoder
will be created.
Exceptions
TextEncoder()
throws no exceptions since Firefox 48 and Chrome 53
Note: Prior to Firefox 48 and Chrome 53 an exception would be thrown for an unknown encoding type.
Specifications
Specification | Status | Comment |
---|---|---|
EncodingThe definition of 'TextEncoder()' in that specification. | Living Standard | Initial definition |
Browser compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome Full support 53 Full support 53 Notes' Does not accept parameters. Supports only Notes' Throws |
Edge Full support 79 Full support 79 Notes' Does not accept parameters. Supports only |
Firefox Full support 48 Full support 48 Notes' The constructor accepts an encoding type label argument, but the value is ignored. Only Notes' If the encoding type label argument is invalid, then a Notes' If the encoding type label argument is invalid, then a Notes' Firefox 18 implemented an earlier and slightly different version of the specification. |
IE
No support No |
Opera
Full support 25 |
Safari
Full support 10.1 |
WebView Android
Full support 38 |
Chrome Android
Full support 38 |
Firefox Android Full support 48 Full support 48 Notes' The constructor accepts an encoding type label argument, but the value is ignored. Only Notes' If the encoding type label argument is invalid, then a Notes' If the encoding type label argument is invalid, then a Notes' Firefox 18 implemented an earlier and slightly different version of the specification. |
Opera Android
? |
Safari iOS
Full support 10.3 |
Samsung Internet Android
Full support 3.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- See implementation notes.'
- See implementation notes.
See also
- The
TextEncoder
interface it belongs to.
TextEncoder() by Mozilla Contributors is licensed under CC-BY-SA 2.5.