This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.
The TextEncoder.encode
method returns a Uint8Array
containing the text given in parameters encoded with the specific method for that TextEncoder
object.
SyntaxEdit
b1 = encoder.encode(buffer, options); b2 = encoder.encode(buffer);
Parameters
- buffer
- Is a
DOMString
containing the text to encode. - options Optional
- Is a
TextEncodeOptions
dictionary with the property:
stream
- A
Boolean
flag indicating if the encoding can be done in chunks or not. It defaults tofalse
.
SpecificationsEdit
Specification | Status | Comment |
---|---|---|
Encoding The definition of 'TextEncoder.encode()' in that specification. |
Living Standard | Initial definition. |
Browser compatibilityEdit
[1] An earlier, and slightly different, version of the specification was implemented in Firefox 18.
See alsoEdit
- The
TextEncoder
interface it belongs to.