我想讀取一個JavaScript中的二進制文件,這個二進制文件可以通過XMLHttpRequest獲得並且能夠處理這些數據。從我的研發,我發現讀一個二進制文件數據到一個數組如何將二進制數據讀取到Javascript中的字節數組?
var xhr = new XMLHttpRequest();
xhr.open('GET', '/binary_And_Ascii_File.obj', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
var uInt8Array = new Uint8Array(this.response);
};
我怎麼這個二進制數據數組轉換爲人類可讀的字符串這種方法嗎?
'XMLHttpRequest.responseType 「arrayBuffer」 在Chrome supported.'。 –
此問題可能有助於他人:http://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers –