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

135
Vistas
Javascript encoding problem when downloading files

I have a page which converts images to ANSI colored batch console art, with a download button, but it gives errors when I open it. In notepad I noticed it says "Unix (LF)" on the bottom right corner. All my other batch scripts are "Windows (CRLF)". How can I encode it to the correct format? Is that the problem?

example from the batch (one pixel is one █ character, ESC is the ANSI escape character):

@echo off
chcp 65001 >nul
cls

echo ESC[38;2;21;20;26m█ESC[38;2;21;20;26m█

...

pause >nul

enter image description here

Those are the errors. It works perfectly when I paste the code into a new .bat file so it's definitely some sort of encoding problem.

The js that handles the download:

var dwn = $('#download') // Download button

dwn.download = 'console-img.bat'
dwn.href = URL.createObjectURL(new Blob([result], { type: 'text/plain' }))

// result is a string containing the code
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Okay, after a bit of researching about CRLF / LF I found the solution.

Replace all the \n in your string to \r\n

about 4 years ago · Santiago Gelvez Denunciar
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