Answers for "convert binary data to string in js"

1

converting binary to text js

function binaryAgent(str) {

var newBin = str.split(" ");
var binCode = [];

for (i = 0; i < newBin.length; i++) {
    binCode.push(String.fromCharCode(parseInt(newBin[i], 2)));
  }
return binCode.join("");
}
binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100');
//translates to "Aren't"
Posted by: Guest on October-21-2020
0

how to convert string into binary in javascript

// Text to Binary
function text2Binary(string) {
    return string.split('').map(function (char) {
        return char.charCodeAt(0).toString(2);
    }).join(' ');
}
text2Binary("Hello World");
Posted by: Guest on January-08-2022

Code answers related to "convert binary data to string in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language