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 argument is provided, the stringDecoder.write() method is called once with the data before returning the remaining buffer input.
stringDecoder.end( [buffer] )
Parameters: This function accepts single parameter as mentioned above and described below:
- buffer: It is a Buffer, TypedArray, or DataView that contains the bytes that have to be decoded. It is an optional parameter.
Return Value: It returns the remaining input stored in a buffer as a string.
Below programs illustrate the stringDecoder.end() method in Node.js:
Decoded Text: GeeksforGeeks Decoding the Euro Symbol: €
Complete Cent Symbol: ¢ Cent Symbol using write(): Cent Symbol using end(): ??
Please Login to comment...