Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

266
Views
Convert a Buffer to a string representing the buffer as binary in Node.js

Not sure how to describe it better than an example:

var data = Buffer.alloc(2);
data.writeUInt8(0xFF, 0);
data.writeUInt8(0x80, 1);

console.log(data.toString('exampleSomething'));
// something like what I would want it to print:
// "11111111 10000000"

I just want to have a string using 0s and 1s for each byte. Should I just do this manually (parse as a number then .toString(2) each byte) or is there a better way?

Example of "manually":

var outString = "";
data.forEach(e => {
    outString += e.toString(2).padStart(8, "0") + " ";
});
console.log(outString);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!