Node.js String Decoder Complete Reference
The string Decoder module provides an API for decoding Buffer objects into strings.
Example:
Javascript
const { StringDecoder } = require( "string_decoder" );
const decoder = new StringDecoder( "utf-8" );
const text_one = Buffer.from( "GeeksforGeeks" , "utf-8" );
let decoded_text = decoder.write(text_one);
console.log( "Decoded Text:" , decoded_text);
|
Output:
Decoded Text: GeeksforGeeks
The Complete List of String Decoder are listed below:
Class: StringDecoder
Class: StringDecoder Methods
|
Description
|
stringDecoder.end() |
Return all the remaining input stored in the internal buffer as a string. |
stringDecoder.write() |
Return a decoded string from the given Buffer, TypedArray, or DataView. |
Last Updated :
23 Feb, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...