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

285
Views
Create and download an UTF8 plain text file from JS (browser)

I'm stucking on a problem that I cannot understand. I got an HTML page, declaring <meta charset="utf-8" />, attempting to create and download a text file, containing some UTF8 characters. The text is stored inside a JS variable and I'm trying to download the variable content as text file using the DataURI API. This is the code:

const myText = "àòùè";
const uriContent = "data:text/plain;charset=utf-8;base64," + btoa(myText);
const element = document.createElement('a');
element.setAttribute('href', uriContent);
element.setAttribute('download', "example_filename.log");
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);

The resulting file is saved as ISO8859-15 and not in UTF-8 as declared in dataURI. It results in strange characters due to wrong encoding.

The encoding is checked using the file command under UNIX:

file example_filename.log
example_filename.log: ISO-8859 text
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!