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

322
Vistas
How can I prevent corruption of binary characters when calling response.text() in javascript?

I am attempting to retrieve a .woff font file from a url, convert the bytes to hex and then store the file in the new encoded format.

Currently, I have a function which does just this however the file somehow get's corrupted somewhere inbetween.

The function which I have currently is as following:

function getfont(url) {
    fetch(url).then(function(response) {
        return response.text();
    }).then(function(text) {
        var hex = [];
        for (var i = 0; i < text.length; i++) {
            hex.push(text.charCodeAt(i).toString(16));
        }
        console.log(hex.join(''))
    })
}

I have checked the response before encoding and do not seem to see anything obvious which clues me to how the file is getting corrupted after it is being encoded and I have also checked that the font stored at the url works beforehand.

How would I go about fetching the .woff file and storing it as an encoded string without any corruption and being able to use the file after decoding it?

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