I have created a function to convert ascii to decimal:
function asciiToDecimal(text) {
var decimal = "";
for (var i=0; i < text.length; i++) {
decimal += text[i].charCodeAt(0).toString(10) + " ";
}
return decimal;
}
and now I want to convert binary to decimal directly. I have tried to convert to ascii and then decimal but that is not always possible. I have seen a couple of other SO Q&A that present a function, but the answer is usually not the the desired output (see below).
Input:
01101101 01111001 00100000 01101110 01100001 01101101 01100101 00100000 01101001 01110011 00100000 01101010 01101001 01101101 00111111
Desired Output:
109 121 32 110 97 109 101 32 105 115 32 106 105 109 63
How can this be achieved?