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

284
Visualizações
Encoding issue when saving files with javascript?

i've been trying all day to setup a function that creates a file from plaintext or a stream in a razor page. i create csv plaintext in a backend and send it to a frontend where i can save it to a file.

most of the things i have tried have worked perfectly so far, i can save what i get from my backend. but when i look at the file, the character 'ø' has been replaced with "ø". i have tried specifying utf-8 format and encoded it as html or base64 and plaintext and nothing seems to work.

function saveFile(name, type, data) {
   var a = $("<a style='display: none;'/>");
   var url = window.URL.createObjectURL(new Blob([data], { type: type }));
   a.attr("href", url);
   a.attr("download", name);
   $("body").append(a);
   a[0].click();
   window.URL.revokeObjectURL(url);
   a.remove();
}

is the way my code currently looks. any ideas? thank you

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It actually worked perfectly, I later realized excel was trying to read it with american text which doesn't contain æ ø å. opening it with notepad showed what i was expecting

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