Web TextEncoder API | TextEncoder encode() method Last Updated : 20 Aug, 2019 Comments Improve Suggest changes Like Article Like Report In HTML there is a TextEncoder Interface which has a method encode() which returns an integer array containing the input parameter in encoded form. Syntax: var str = encoder.encode( str ); Return: It return an Uint8array that contains the text which is given in parameters encoded with the specific method for that TextEncoder object. Example: This example uses TextEncoder encode() method. html <!DOCTYPE html> <html> <head> <title> Web TextEncoder API | TextEncoder encode() method </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3>Web TextEncoder API | TextEncoder encode() method</h3> <button onclick="getTextEncoder ();"> Get encoded form </button> <p>Text = "Welcome to GeeksforGeeks"</p> <p id='TextEncoder'></p> <script type="text/javascript"> function getTextEncoder() { var string = "geeksforgeeks is best"; var textEncoder = new TextEncoder(); let encoded = textEncoder.encode(string); document.getElementById("TextEncoder").innerHTML = "Encoded form:" + encoded; } </script> </body> </html> Output: Before clicking the button: After clicking the button: Supported Browsers: The browsers supported by TextEncoder encode() method are listed below: Google Chrome 38 Firefox 19 Opera 25 Safari 10.1 Comment More infoAdvertise with us Next Article Web TextEncoder API | TextEncoder encode() method D DeepakDev Follow Improve Article Tags : JavaScript Web Technologies HTML Web-API Similar Reads Web API | TextDecoder decode() Method The decode() method in TextDecoder API is used to takes a stream of bytes as input and emits a stream of code points. The TextEncoder decode() method takes an ArrayBuffer containing the encoded data and options object and returns the original string (i.e. decoded string). Syntax: decoder.decode(buff 2 min read Web API TextEncoder encodeInto() Method The encodeInto() method in TextEncoder API is used to take stream of points and emits the stream of UTF-8 bytes. All instances of TextEncoder only support UTF-8 encoding. The TextEncoder.encodeInto() takes a string to encode and an array to hold the encoded result and returns an object back. Syntax: 2 min read TextDecoder Web API | TextDecoder constructor In HTML there is a TextDecoder Interface of which we can create a TextDecoder object for the encoding specified in parameter. Syntax: decoder = new TextDecoder( utf-Label, option ); Parameters: This constructor accepts two parameters which are mentioned above and described below: utf-Label: Label of 2 min read Node.js stringDecoder.end() Method The stringDecoder.end() method is used to return all the remaining input stored in the internal buffer as a string. This method ensures that any incomplete UTF-8 and UTF-16 characters are replaced with substitution characters that are appropriate for character encoding. When the optional buffer argu 2 min read Node.js stringDecoder.write() Method The stringDecoder.write() method is used to return a decoded string from the given Buffer, TypedArray or DataView. This method also ensures that any incomplete multibyte characters at the end of the buffer are omitted from the returned string. These characters are stored in an internal buffer for th 2 min read Node.js TextEncoder The TextEncoder is an interface that takes a stream of code points as input and emits a stream of encoded UTF-8 codes. This is provided in NodeJS as an implementation of the WHATWG Encoding Standard 'TextEncoder' API. All instances of TextEncoder only support UTF-8 encoding. UTF-8: It is an encoding 2 min read Node.js Stream writable.setDefaultEncoding() Method The writable.setDefaultEncoding() method is an inbuilt application programming interface of Stream module which is used to set the default encoding for a Writable stream. Syntax: writable.setDefaultEncoding( encoding ) Parameters: This method accepts single parameter encoding which holds the encodin 2 min read Node.js Stream readable.setEncoding() Method The readable.setEncoding() method in a Readable Stream is used to set the encoding of the data read. Syntax: readable.setEncoding( encoding ) Parameters: This method accepts single parameter encoding which holds the encoding type. Return Value: It returns the data in the encoded form. Below examples 1 min read How to Encode and Decode a URL in PHP? Encoding and decoding URLs in PHP are essential tasks when working with web applications, especially for handling user input and constructing query strings. URL encoding ensures that special characters are properly represented in URLs, preventing errors or unexpected behavior during data transmissio 2 min read TypeScript String.fromCharCode() Method The fromCharCode() is an inbuilt TypeScript String method. It mainly changes Unicode code points within the Basic Multilingual Plane (BMP) into strings. Although it provides a method for dealing with characters through typing on a keyboard it has restrictions when it comes to characters, outside the 1 min read Like