Created
December 1, 2021 14:22
-
-
Save Lokno/be6a3d5f277e4c67876608026c7609af to your computer and use it in GitHub Desktop.
Binary to character string in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function b2s(s) { | |
var b = s.replace(/[\s\t\n\r]/g, '').match(/.{1,8}/g) | |
var o = ""; | |
for (i = 0; i < b.length; i++) o += String.fromCharCode(parseInt(b[i], 2)); | |
return o; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment