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

279
Vistas
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
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