Browse files

Binary ↔ ASCII converter: allow spaces between octets

Because it is customary to separate the groups of 8 bits by spaces, allow
the input to have spaces, too. Because `parseInt('    01100001  ', 2)` is
the same as `parseInt('01100001', 2)`, this has no effect on the outcome.

Example input: http://pastebin.com/NKbnh8q8
  • Loading branch information...
1 parent 06d4c34 commit 8b4c3e9530253b2254bc230154d96c08636ff5ad @janmoesen committed Feb 16, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 binary-ascii/eff.js
View
4 binary-ascii/eff.js
@@ -4,9 +4,9 @@
ascii = textareas[0],
binary = textareas[1],
permalink = document.getElementById('permalink'),
- regexBinaryGroup = /[01]{8}/g,
+ regexBinaryGroup = /\s*[01]{8}\s*/g,
regexAnyCharacter = /[\s\S]/g,
- regexBinary = /^([01]{8})*$/,
+ regexBinary = /^(\s*[01]{8}\s*)*$/,
regexExtendedASCII = /^[\x00-\xff]*$/,
// http://mathiasbynens.be/notes/localstorage-pattern
storage = (function() {

0 comments on commit 8b4c3e9

Please sign in to comment.