Node.js String Decoder Complete Reference
Improve
The string Decoder module provides an API for decoding Buffer objects into strings.
Example:
Javascript
// Node.js program to demonstrate the // stringDecoder.write() Method // Import the string_decoder module // and get the StringDecoder class // using object destructuring const { StringDecoder } = require("string_decoder"); // Create a new instance of the 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. |
Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!
Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Share your thoughts in the comments

