| Viewed 124 times

Binary to ASCII Conversion in javaScript?


Characters can be in the range of "00000000" to "11111111", which means every eight digits of binary input represents a single character.

1 Answer
Mohammad Qandeel
Answered
16

This can be done using fromCharCode() function 

See this example it receives a text variable, then returns the corresponding value in ASCII  table

function binaryConversion(str) {
 return str.replace(/([0-1]{8})/g,x=>String.fromCharCode(parseInt(x,2)));
}


Related Questions