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

138
Views
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 answers
Answer question

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 Report
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!