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
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
Okay, after a bit of researching about CRLF / LF I found the solution.
Replace all the \n in your string to \r\n