0

I'm trying to read and write a binary file (fingerprint). The contents of binary files are below:

tL.|¢Tn>ªÏû•"q‚º†k‹ë²¶zño‰JÇ5»

I read this file with the following command:

var input, file, fr; 
input = document.getElementById('fileinput'); 
file = input.files[0]; 
fr = new FileReader(); 
fr.onload = receivedBinary; 
fr.readAsBinaryString(file);     

function receivedBinary() {
    showResult(fr, "Binary");
}

function showResult(fr, label) {
    var result;
    result = fr.result;
    alert(result);    
 }   

But it's happening a problem. When I see the file content that has been read, some characters are not loaded. The following file after read:

tL.|¢Tn>ªÏû"qºkë²¶zñoJÇ5»

For example, do you realize that the symbol "•", between characters û and " was not read.

Why? What should I do to read and write all the characters?

5
  • These differences are often due to character encoding. If it's a binary file, why are you trying to read it as a String? Commented May 31, 2015 at 12:59
  • 1
    possible duplicate of Difference between readAsBinaryString and readAsText using FileReader Commented May 31, 2015 at 13:00
  • Then, what command must I use instead readAsBinaryString? Commented May 31, 2015 at 13:03
  • Uhm, alerting binary is probably not a very good form of debugging Commented May 31, 2015 at 13:03
  • Try to use Uint8Array Commented May 31, 2015 at 13:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.