Skip to content

Instantly share code, notes, and snippets.

@eyecatchup
eyecatchup / ascii-binary-converter.js
Last active November 6, 2023 20:03
JavaScript native ASCII to Binary / Binary to ASCII convert functions.
// ABC - a generic, native JS (A)scii(B)inary(C)onverter.
// (c) 2013 Stephan Schmitz <eyecatchup@gmail.com>
// License: MIT, http://eyecatchup.mit-license.org
// URL: https://gist.github.com/eyecatchup/6742657
var ABC = {
toAscii: function(bin) {
return bin.replace(/\s*[01]{8}\s*/g, function(bin) {
return String.fromCharCode(parseInt(bin, 2))
})
},