TextEncoder
An implementation of the WHATWG Encoding Standard TextEncoder API. All
instances of TextEncoder only support UTF-8 encoding.
TextEncoder takes a stream of code points as input and emits a stream of UTF-8 bytes.
See also
const encoder = new TextEncoder();const uint8array = encoder.encode('a string to encode');Constructor
new TextEncoder()Returns a newly constructed TextEncoder that will generate a byte stream with UTF-8 encoding.
Properties
The TextEncoder.encoding read-only property returns a string containing the name of the encoding algorithm used by the specific encoder. It is always set to the value "utf-8".
Methods
encode
View sourceUTF-8 encodes the input string and returns a Uint8Array containing the encoded bytes.
Parameters
- input: stringoptional
Returns