Created
July 31, 2015 05:20
-
-
Save JavaScript-Packer/62adec693cdd691778dd to your computer and use it in GitHub Desktop.
Base64 decoder with UTF-8 decode of encoded ascii - unBase64 Button function for http://www.whak.ca/packer/LZW(HAK).htm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a2b(r) { | |
function utf(r) { | |
for (var t = "", e = 0, o = c1 = c2 = 0; e < r.length; ) o = r.charCodeAt(e), 128 > o ? (t += String.fromCharCode(o), | |
e++) :o > 191 && 224 > o ? (c2 = r.charCodeAt(e + 1), t += String.fromCharCode((31 & o) << 6 | 63 & c2), | |
e += 2) :(c2 = r.charCodeAt(e + 1), c3 = r.charCodeAt(e + 2), t += String.fromCharCode((15 & o) << 12 | (63 & c2) << 6 | 63 & c3), | |
e += 3); | |
return t; | |
} | |
var t, X = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", e, o, a, h, n = "", c = 0; | |
for (r = r.replace(/[^A-Za-z0-9\+\/\=]/g, ""); c < r.length; ) t = X.indexOf(r.charAt(c++)), | |
e = X.indexOf(r.charAt(c++)), a = X.indexOf(r.charAt(c++)), h = X.indexOf(r.charAt(c++)), | |
t = t << 2 | e >> 4, e = (15 & e) << 4 | a >> 2, o = (3 & a) << 6 | h, n += String.fromCharCode(t), | |
64 != a && (n += String.fromCharCode(e)), 64 != h && (n += String.fromCharCode(o)); | |
return utf(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment