简体   繁体   中英

Javascript html5 how to convert binary data into string

    var reader = new FileReader();
    var rawData = new ArrayBuffer();            
    //console.log(1);

    reader.onload = function(e) {


        var rawData = e.target.result; //binary data
        console.log(rawData);


    }

I want to see explicitly the binary raw data as a text string, is that possible?, cause the only thing i see when logging is:

ArrayBuffer {} 

你可以试试

console.log(String.fromCharCode.apply(null, new Uint16Array(rawData)));

This is what'I've needed:

reader.readAsBinaryString(file);

then the data is available raw

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM