I have a file that's encoded with UTF-16 and the encoded string has characters such as à and ÷. The code I use to read the file is:
var reader = new FileReader();
reader.readAsArrayBuffer(real_file_button.files[0]);
reader.onloadend = function (evt) {
if (evt.target.readyState == FileReader.DONE) {
var arrayBuffer = evt.target.result,
array = new Uint8Array(arrayBuffer);
for (var i = 0; i < array.length; i++) {
fileByteArray.push(array[i]);
}
}
}
but since it is reading it as UTF-8 the à and ÷ characters get converted to �. How can I get a byte array of the file while keeping the correct encoding?
fileByteArray, what's the point of copying thearrayyou already have into it?