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

321
Views
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
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!