Skip to content

Instantly share code, notes, and snippets.

@plugnburn
Last active Aug 29, 2015
Embed
What would you like to do?
Zero-Width encoder/decoder with autodetection feature in 400 bytes
ZW={enc:function(s){return unescape(encodeURIComponent(s)).split("").map(function(c){return("00000000"+c.charCodeAt(0).toString(2)).substr(-8)}).join("").replace(/0/g,"\u200b").replace(/1/g,"\u200c")},dec:function(s){return(s=s.match(/[\u200b\u200c]{8}/g))&&decodeURIComponent(escape(s.map(function(c){return String.fromCharCode(parseInt(c.replace(/\u200b/g,0).replace(/\u200c/g,1),2))}).join("")))}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment