From 8b4c3e9530253b2254bc230154d96c08636ff5ad Mon Sep 17 00:00:00 2001 From: Jan Moesen Date: Thu, 16 Feb 2012 16:35:14 +0100 Subject: [PATCH] =?UTF-8?q?Binary=20=E2=86=94=20ASCII=20converter:=20allow?= =?UTF-8?q?=20spaces=20between=20octets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- binary-ascii/eff.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binary-ascii/eff.js b/binary-ascii/eff.js index 729259f..9d0a6d1 100644 --- a/binary-ascii/eff.js +++ b/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() {