I'm working on this code where I want to download a byte array, and its working at this point, but the downloaded file is encoded in ascii.
The downloaded file shows "65,66,67,0,0,0,0,0,0,0"
but I was expecting "ABC"
How can I change this code to get this file in binary format?
<!DOCTYPE html>
<html>
<body>
<h1>Writing a binary file</h1>
<script>
var dados = new Int8Array(10);
dados[0]=65;
dados[1]=66;
dados[2]=67;
function download()
{
let element = document.createElement('a');
element.setAttribute('href', 'data:application/octet-stream,' + dados );
element.setAttribute('download', "teste.bin" );
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
download();
</script>
</body>
</html>