From 69e14b3ab269cd1dd853ed31f5a5bbca8982381b Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Wed, 11 Jun 2008 17:02:12 +0000 Subject: Simplify base64 decoding --- encoding.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/encoding.js b/encoding.js index 52265de..6c641df 100644 --- a/encoding.js +++ b/encoding.js @@ -118,12 +118,12 @@ function decode_quotedprintable( str ) { } function dec(x) { - if (x>='A' && x<='Z') return ( x.charCodeAt(0) & 0xff ) - 65; - if (x>='a' && x<='z') return ( x.charCodeAt(0) & 0xff ) - 97 + 26; - if (x>='0' && x<='9') return ( x.charCodeAt(0) & 0xff ) - 48 + 26 + 26; + if (x>=65 && x<=90 ) return x - 65; + if (x>=97 && x<=122) return x - 97 + 26; + if (x>=48 && x<=57 ) return x - 48 + 26 + 26; switch (x) { - case '+': return 62; - case '/': return 63; + case 43: return 62; + case 47: return 63; default: return -1; } } @@ -133,7 +133,8 @@ function decode_base64( str ) { var outstring = ""; for( var i=0; i