JavaScripture
Contribute via GitHub Feedback

TextEncoder : Object

Encodes a String into a UTF-8 stream of bytes.

Constructors

new TextEncoder() : TextEncoder

Creates an encoder that can convert strings to a sequence of UTF-8 bytes.

Example:

Run

Results:

 

Instance Properties

encoding : String  

Returns the encoding method. Currently only 'utf-8' is supported.

Example:

Run

Results:

 

Instance Methods

encode(value = '' : String) : Uint8Array

Converts value into a sequence of UTF-8 bytes.

Example:

Run

Results:

 

encodeInto(value : String, destination : Uint8Array) : Object
return : {
read :NumberThe number of UTF-16 characters read from value.
written :NumberThe number of bytes written to destination.
}

Writes value as a sequence of UTF-8 bytes into destination. Returns information about the number of characters read from value and bytes written to destination.

Example:

Run

Results: