In javascript I want to download(get) binary files from server and use its bytes. I use this code:
$.get('/file.mp4', function(data) {
var bytes = new Uint8Array(data.length);
for (var i=0; i<data.length; i++) {
bytes[i] = data.charCodeAt(i);
}
});
But there is a problem: some characters of data variable have ASCII code grater than 255 (like "ą" --> ASCII:261)!! and charCodeAt(i) return 65533 for them also when i use console.log(data[i]) output is "�".
I tested "ą".charCodeAt(0) and output was 261 so I guess that problem is in data that received by get method not in charCodeAt method. Is there an alternative method to download binary files??
arrayBufferinXMLHttpRequest