Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

324
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda