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

225
Views
Convert byte array to encoded UFT8 in Node

I'm looking to convert a byte array to encoded UFT8 in Node. In Python, I've used the bytes() method to convert however I haven't been able to find a similar function in Node.

An example input would be [0, 1, 66, 119, 208] which would ideally return \x00\x01Bw\xd0

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Node.js these days pretty much follows browser standards, as such the TextDecoder https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/TextDecoder is part of node.

So this code below will work in browser or node.

const r = new TextDecoder().decode(new Uint8Array([0, 1, 66, 119, 208]));

console.log(r);
console.log(encodeURI(r));
console.log(JSON.stringify(r));

The question was asking for how to convert byte to utf-8. The above does this.

The OP was more after a encoding compatible with C strings-> This repository looks like it should do the trick.. https://github.com/harold4/node-string-escape-for-cpp/blob/master/index.js

about 4 years ago · Juan Pablo Isaza Report
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!