Search code examples
javascripthtmlinternet-explorer-10filereader

Alternative to readAsBinaryString for IE10


It seems that readAsBinaryString, a method of the JavaScript FileReader object, is not supported in IE10. I've tried the following, as suggested in this HTML5 Rocks article:

String.fromCharCode.apply(null, new Uint16Array(buffer));

However, this results in an Out of stack space error.


Solution

  • I found the answer here:

    var binary = "";
    var bytes = new Uint8Array(buffer);
    var length = bytes.byteLength;
    for (var i = 0; i < length; i++) {
      binary += String.fromCharCode(bytes[i]);
    }