JavaScript Runtime APIs - Encoding
TextEncoder() constructor
Section titled TextEncoder() constructorTextEncoder()
returns a built TextEncoder
that generates a UTF-8-encoded data transmission.
Syntax
Section titled Syntaxencode() method
Section titled encode() methodThe encode()
method codes a string
object.
Syntax
Section titled SyntaxProperties
Section titled Propertiesstring
A USVString containing the text to be coded.
TextDecoder() constructor
Section titled TextDecoder() constructorTextDecoder()
returns a TextDecoder
object that generates a code-point data transmission.
Syntax
Section titled Syntaxdecode() method
Section titled decode() methoddecode()
method decodes an object using a previously created method in TextDecoder()
.
Sintaxe
Section titled SintaxeProperties
Section titled Propertiesbuffer
Optional
Either an ArrayBuffer or ArrayBufferView containing the text to be decoded.
options
Optional
It’s a TextDecodeOptions dictionary with the property:
- stream:
boolean
indicating that each additional data will follow in subsequent calls todecode()
. Set to true if processing the data in lumps, and false for the final chunk or if the data is not blocked. The standard configuration is false.
Example
Section titled ExampleFor more information on encode and decode, visit MDN Web Docs.
Contributors