Skip to content

Instantly share code, notes, and snippets.

@Lokno
Created December 1, 2021 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lokno/be6a3d5f277e4c67876608026c7609af to your computer and use it in GitHub Desktop.
Save Lokno/be6a3d5f277e4c67876608026c7609af to your computer and use it in GitHub Desktop.
Binary to character string in Javascript
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