Created
May 17, 2010 09:01
-
-
Save mattn/403548 to your computer and use it in GitHub Desktop.
C++版aaencode/jjencode
This file contains 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
// MSVC: cl /wd4819 /EHsc aaencode.cxx | |
// gcc: g++ -o aaencode aaencode.cxx | |
// | |
// usage: aaencode < foo.js # jjencode | |
// aaencode -aa < foo.js # aaencode | |
#include <sstream> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
static char utf8len_tab[256] = { | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, | |
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1, | |
}; | |
static char utf8len_tab_zero[256] = { | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, | |
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, | |
}; | |
int utf_ptr2len(unsigned char* p) { | |
int len; | |
int i; | |
if (*p == 0) | |
return 0; | |
len = utf8len_tab[*p]; | |
for (i = 1; i < len; ++i) | |
if ((p[i] & 0xc0) != 0x80) | |
return 1; | |
return len; | |
} | |
int utf_ptr2char(unsigned char* p) { | |
int len; | |
if (p[0] < 0x80) /* be quick for ASCII */ | |
return p[0]; | |
len = utf8len_tab_zero[p[0]]; | |
if (len > 1 && (p[1] & 0xc0) == 0x80) { | |
if (len == 2) | |
return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f); | |
if ((p[2] & 0xc0) == 0x80) { | |
if (len == 3) | |
return ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) | |
+ (p[2] & 0x3f); | |
if ((p[3] & 0xc0) == 0x80) { | |
if (len == 4) | |
return ((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) | |
+ ((p[2] & 0x3f) << 6) + (p[3] & 0x3f); | |
if ((p[4] & 0xc0) == 0x80) { | |
if (len == 5) | |
return ((p[0] & 0x03) << 24) + ((p[1] & 0x3f) << 18) | |
+ ((p[2] & 0x3f) << 12) + ((p[3] & 0x3f) << 6) | |
+ (p[4] & 0x3f); | |
if ((p[5] & 0xc0) == 0x80 && len == 6) | |
return ((p[0] & 0x01) << 30) + ((p[1] & 0x3f) << 24) | |
+ ((p[2] & 0x3f) << 18) + ((p[3] & 0x3f) << 12) | |
+ ((p[4] & 0x3f) << 6) + (p[5] & 0x3f); | |
} | |
} | |
} | |
} | |
/* Illegal value, just return the first byte */ | |
return p[0]; | |
} | |
void aaencode() { | |
const char* b[] = { | |
"(c^_^o)", // (c^_^o) | |
"(\xef\xbe\x9f\xce\x98\xef\xbe\x9f)", // (゚Θ゚) | |
"((o^_^o) - (\xef\xbe\x9f\xce\x98\xef\xbe\x9f))", // ((o^_^o) - (゚Θ゚)) | |
"(o^_^o)", // (o^_^o) | |
"(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)", // (゚ー゚) | |
"((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) + (\xef\xbe\x9f\xce\x98\xef\xbe\x9f))", // ((゚ー゚) + (゚Θ゚)) | |
"((o^_^o) +(o^_^o))", // ((o^_^o) +(o^_^o)) | |
"((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) + (o^_^o))", // ((゚ー゚) + (o^_^o)) | |
"((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) + (\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f))", // ((゚ー゚) + (゚ー゚)) | |
"((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) + (\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) + (\xef\xbe\x9f\xce\x98\xef\xbe\x9f))", // ((゚ー゚) + (゚ー゚) + (゚Θ゚)) | |
"(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) .\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89", // (゚Д゚) .゚ω゚ノ | |
"(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) .\xef\xbe\x9f\xce\x98\xef\xbe\x9f\xef\xbe\x89", // (゚Д゚) .゚Θ゚ノ | |
"(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['c']", // (゚Д゚) ['c'] | |
"(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) .\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f\xef\xbe\x89", // (゚Д゚) .゚ー゚ノ | |
"(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) .\xef\xbe\x9f\xd0\x94\xef\xbe\x9f\xef\xbe\x89", // (゚Д゚) .゚Д゚ノ | |
"(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) [\xef\xbe\x9f\xce\x98\xef\xbe\x9f]", // (゚Д゚) [゚Θ゚] | |
}; | |
stringstream r; | |
cout << "\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89= /\xef\xbd\x80\xef\xbd\x8d\xc2\xb4\xef\xbc\x89\xef\xbe\x89 ~\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb //*\xc2\xb4\xe2\x88\x87\xef\xbd\x80*/ ['_']; o=(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) =_=3; " // ゚ω゚ノ= /`m´)ノ ~┻━┻ //*´∇`*/ ['_']; o=(゚ー゚) =_=3; | |
<< "c=(\xef\xbe\x9f\xce\x98\xef\xbe\x9f) =(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)-(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f); (\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) =(\xef\xbe\x9f\xce\x98\xef\xbe\x9f)= (o^_^o)/ (o^_^o);" // c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o); | |
<< "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)={\xef\xbe\x9f\xce\x98\xef\xbe\x9f: '_' ,\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89 : ((\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89==3) +'_') [\xef\xbe\x9f\xce\x98\xef\xbe\x9f] " // (゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] | |
<< ",\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f\xef\xbe\x89 :(\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89+ '_')[o^_^o -(\xef\xbe\x9f\xce\x98\xef\xbe\x9f)] " // ,゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o -(゚Θ゚)] | |
<< ",\xef\xbe\x9f\xd0\x94\xef\xbe\x9f\xef\xbe\x89:((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f==3) +'_')[\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f] }; (\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) [\xef\xbe\x9f\xce\x98\xef\xbe\x9f] =((\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89==3) +'_') [c^_^o];" // ,゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o]; | |
<< "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['c'] = ((\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)+'_') [ (\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)+(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)-(\xef\xbe\x9f\xce\x98\xef\xbe\x9f) ];" // (゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ]; | |
<< "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['o'] = ((\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)+'_') [\xef\xbe\x9f\xce\x98\xef\xbe\x9f];" // (゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚]; | |
<< "(\xef\xbe\x9fo\xef\xbe\x9f)=(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['c']+(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['o']+(\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89 +'_')[\xef\xbe\x9f\xce\x98\xef\xbe\x9f]+ ((\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89==3) +'_') [\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f] + " // (゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + | |
<< "((\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) +'_') [(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)+(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)]+ ((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f==3) +'_') [\xef\xbe\x9f\xce\x98\xef\xbe\x9f]+" // ((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+ | |
<< "((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f==3) +'_') [(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) - (\xef\xbe\x9f\xce\x98\xef\xbe\x9f)]+(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['c']+" // ((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+ | |
<< "((\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)+'_') [(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)+(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)]+ (\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['o']+" // ((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+ | |
<< "((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f==3) +'_') [\xef\xbe\x9f\xce\x98\xef\xbe\x9f];(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['_'] =(o^_^o) [\xef\xbe\x9fo\xef\xbe\x9f] [\xef\xbe\x9fo\xef\xbe\x9f];" // ((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚]; | |
<< "(\xef\xbe\x9f\xce\xb5\xef\xbe\x9f)=((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f==3) +'_') [\xef\xbe\x9f\xce\x98\xef\xbe\x9f]+ (\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) .\xef\xbe\x9f\xd0\x94\xef\xbe\x9f\xef\xbe\x89+" // (゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+ | |
<< "((\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)+'_') [(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f) + (\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)]+((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f==3) +'_') [o^_^o -\xef\xbe\x9f\xce\x98\xef\xbe\x9f]+" // ((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+ | |
<< "((\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f==3) +'_') [\xef\xbe\x9f\xce\x98\xef\xbe\x9f]+ (\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89 +'_') [\xef\xbe\x9f\xce\x98\xef\xbe\x9f]; " // ((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; | |
<< "(\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)+=(\xef\xbe\x9f\xce\x98\xef\xbe\x9f); (\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)[\xef\xbe\x9f\xce\xb5\xef\xbe\x9f]='\\\\'; " // (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\'; | |
<< "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f).\xef\xbe\x9f\xce\x98\xef\xbe\x9f\xef\xbe\x89=(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f+ \xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9f)[o^_^o -(\xef\xbe\x9f\xce\x98\xef\xbe\x9f)];" // (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)]; | |
<< "(o\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9fo)=(\xef\xbe\x9f\xcf\x89\xef\xbe\x9f\xef\xbe\x89 +'_')[c^_^o];" // (o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o]; TODO | |
<< "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) [\xef\xbe\x9fo\xef\xbe\x9f]='\\\"';" // (゚Д゚) [゚o゚]='\"'; | |
<< "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['_'] ( (\xef\xbe\x9f\xd0\x94\xef\xbe\x9f) ['_'] (\xef\xbe\x9f\xce\xb5\xef\xbe\x9f+" // (゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+ | |
<< "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)[\xef\xbe\x9fo\xef\xbe\x9f]+ "; // (゚Д゚)[゚o゚]+ | |
string us; | |
while(!cin.eof()) { | |
int n = 0; | |
if (us.empty()) { | |
char c = 0; | |
cin.get(c); | |
us += c; | |
for (int l = 1, ll = utf8len_tab[(unsigned char)c]; l < ll; l++) { | |
if (cin.eof()) break; | |
cin.get(c); | |
us += c; | |
} | |
} | |
n = utf_ptr2char((unsigned char*)us.c_str()); | |
if (n == 0) break; | |
us.erase(0, utf_ptr2len((unsigned char*)us.c_str())); | |
stringstream ss; | |
string ns; | |
cout << "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)[\xef\xbe\x9f\xce\xb5\xef\xbe\x9f]+"; // (゚Д゚)[゚ε゚]+ | |
if (n <= 127) { | |
ss << oct << int(n) << dec && ss >> ns; | |
for (string::iterator it = ns.begin(); it != ns.end(); it++) { | |
cout << b[string("01234567").find(tolower(*it))] << "+ "; | |
} | |
} else { | |
ss << hex << int(n) << dec && ss >> ns; | |
cout << "(o\xef\xbe\x9f\xef\xbd\xb0\xef\xbe\x9fo)+ "; // (o゚ー゚o)+ | |
ns.insert(0, "000"); | |
ns = ns.substr(ns.size() - 4); | |
for (string::iterator it = ns.begin(); it != ns.end(); it++) { | |
cout << b[string("0123456789abcdef").find(tolower(*it))] << "+ "; | |
} | |
} | |
} | |
cout << "(\xef\xbe\x9f\xd0\x94\xef\xbe\x9f)[\xef\xbe\x9fo\xef\xbe\x9f]) (\xef\xbe\x9f\xce\x98\xef\xbe\x9f)) ('_');"; // (゚Д゚)[゚o゚]) (゚Θ゚)) ('_'); | |
cout.flush(); | |
} | |
void jjencode(const char* gv = "$") { | |
const char* b[] = { "___", "__$", "_$_", "_$$", "$__", "$_$", "$$_", "$$$", "$___", "$__$", "$_$_", "$_$$", "$$__", "$$_$", "$$$_", "$$$$" }; | |
cout << | |
gv << "=~[];" << | |
gv << "={___:++" << gv << ",$$$$:(![]+\"\")[" << gv << "],__$:++" << gv << ",$_$_:(![]+\"\")[" << gv << "],_$_:++" << | |
gv << ",$_$$:({}+\"\")[" << gv << "],$$_$:(" << gv << "[" << gv << "]+\"\")[" << gv << "],_$$:++" << gv << ",$$$_:(!\"\"+\"\")[" << | |
gv << "],$__:++" << gv << ",$_$:++" << gv << ",$$__:({}+\"\")[" << gv << "],$$_:++" << gv << ",$$$:++" << gv << ",$___:++" << gv << ",$__$:++" << gv << "};" << | |
gv << ".$_=" << | |
"(" << gv << ".$_=" << gv << "+\"\")[" << gv << ".$_$]+" << | |
"(" << gv << "._$=" << gv << ".$_[" << gv << ".__$])+" << | |
"(" << gv << ".$$=(" << gv << ".$+\"\")[" << gv << ".__$])+" << | |
"((!" << gv << ")+\"\")[" << gv << "._$$]+" << | |
"(" << gv << ".__=" << gv << ".$_[" << gv << ".$$_])+" << | |
"(" << gv << ".$=(!\"\"+\"\")[" << gv << ".__$])+" << | |
"(" << gv << "._=(!\"\"+\"\")[" << gv << "._$_])+" << | |
gv << ".$_[" << gv << ".$_$]+" << | |
gv << ".__+" << | |
gv << "._$+" << | |
gv << ".$;" << | |
gv << ".$$=" << | |
gv << ".$+" << | |
"(!\"\"+\"\")[" << gv << "._$$]+" << | |
gv << ".__+" << | |
gv << "._+" << | |
gv << ".$+" << | |
gv << ".$$;" << | |
gv << ".$=(" << gv << ".___)[" << gv << ".$_][" << gv << ".$_];" << | |
gv << ".$(" << gv << ".$(" << gv << ".$$+\"\\\"\"+"; | |
cout.flush(); | |
stringstream s; | |
string us; | |
while(!cin.eof()) { | |
int n = 0; | |
if (us.empty()) { | |
char c = 0; | |
cin.get(c); | |
us += c; | |
for (int l = 1, ll = utf8len_tab[(unsigned char)c]; l < ll; l++) { | |
if (cin.eof()) break; | |
cin.get(c); | |
us += c; | |
} | |
} | |
n = utf_ptr2char((unsigned char*)us.c_str()); | |
if (n == 0) break; | |
us.erase(0, utf_ptr2len((unsigned char*)us.c_str())); | |
stringstream ss; | |
string ns; | |
if (n == 0x22 || n == 0x5c) { | |
s << "\\\\\\" << char(n); | |
} else if ((0x20 <= n && n <= 0x2f) || (0x3a <= n && n <= 0x40) || (0x5b <= n && n <= 0x60) || (0x7b <= n && n <= 0x7f)) { | |
s << char(n); | |
} else if ((0x30 <= n && n <= 0x39) || (0x61 <= n && n <= 0x66)) { | |
if (!s.str().empty()) cout << "\"" << s.str() << "\"+"; | |
cout << gv << "." << b[ n < 0x40 ? n - 0x30 : n - 0x57 ] << "+"; | |
s.str(""); | |
s.clear(stringstream::goodbit); | |
} else if (n == 0x6c) { // 'l' | |
if (!s.str().empty()) cout << "\"" << s.str() << "\"+"; | |
cout << "(![]+\"\")[" << gv << "._$_]+"; | |
s.str(""); | |
s.clear(stringstream::goodbit); | |
} else if (n == 0x6f) { // 'o' | |
if (!s.str().empty()) cout << "\"" << s.str() << "\"+"; | |
cout << gv << "._$+"; | |
s.str(""); | |
s.clear(stringstream::goodbit); | |
} else if (n == 0x74) { // 'u' | |
if (!s.str().empty() ) cout << "\"" << s.str() << "\"+"; | |
cout << gv << ".__+"; | |
s.str(""); | |
s.clear(stringstream::goodbit); | |
} else if (n == 0x75) { // 'u' | |
if (!s.str().empty() ) cout << "\"" << s.str() << "\"+"; | |
cout << gv << "._+"; | |
s.str(""); | |
s.clear(stringstream::goodbit); | |
} else if (n < 128) { | |
if (!s.str().empty()) cout << "\"" << s.str(); | |
else cout << "\""; | |
cout << "\\\\\"+"; | |
ss << oct << n << dec && ss >> ns; | |
for (string::iterator it = ns.begin(); it != ns.end(); it++) { | |
cout << gv << "." << b[string("01234567").find(tolower(*it))] << "+"; | |
} | |
s.str(""); | |
s.clear(stringstream::goodbit); | |
} else { | |
if (!s.str().empty()) cout << "\"" << s.str(); | |
else cout << "\""; | |
cout << "\\\\\"+" << gv << "._+"; | |
ss << hex << n << dec && ss >> ns; | |
for (string::iterator it = ns.begin(); it != ns.end(); it++) { | |
cout << gv << "." << b[string("0123456789abcdef").find(tolower(*it))] << "+"; | |
} | |
s.str(""); | |
s.clear(stringstream::goodbit); | |
} | |
} | |
if (!s.str().empty()) cout << "\"" << s.str() << "\"+"; | |
cout << "\"\\\"\")())();" << endl; | |
cout.flush(); | |
} | |
int main(int argc, char* argv[]) { | |
if (argc == 2 && string(argv[1]) == "-aa") | |
aaencode(); | |
else | |
jjencode(); | |
} | |
// vim:set et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment