Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda