#include <cstdlib>
#include <iostream>
#include <fstream>
#define BUFFERLENGTH 500
using namespace std;
// character map for upside down characters
char* charactermap[] = { "¡", ",,", "#", "$", "%", "&", ",", //33-39
")", "(", "*", "+", "´", "-", "'", "/", // 40-47
"0", "1", "☡", "Ɛ", "Ⴙ", "S", "9", "L", "8", "6", // 48-57
":", ";", ">", "=", "<", "¿", "@", // 58-64
"∀", "ʚ", "Ɔ", "p", "∃", "Ⅎ", "פ", // A-G
"H", "I", "ſ", "ﻼ", "ך", "W", "N", "O", "d", "Ὸ", // H-Q
"ʁ", "S", "⊥", "∩", "Λ", "M", "X", "ƛ", "Z", // R-Z
"]", "\\", "[", "^", "¯", ".", // 91-96
"ɐ", "q", "ɔ", "p", "ə", "ɟ", "ƃ", "ɥ", // a-h
"ı", "Ր", "ʞ", "ן", "ɯ", "u", "o", "d", "b", "ɹ", // i-r
"s", "ʇ", "n", "ʌ", "ʍ", "x", "ʎ", "z", // s-z
"}", "|", "{", "~" // 123-126
};
// returns length of word
int getLength(const char* word)
{
int len = 0;
while (word[len] != 0 && len < BUFFERLENGTH)
len++;
if (len == BUFFERLENGTH)
len = 0;
return len-1;
}
// writes upside down character sequence into stream
void writeConvertedChar(ofstream& stream, char c)
{
if (c < 33 || c > 126)
stream << c;
else
stream << charactermap[c-33];
}
int main (int argc, char** argv)
{
// open input file
ifstream fin;
if (argc >= 2)
fin.open(argv[1]);
else
fin.open("data.txt");
if ( !fin )
return 1;
// open output file
ofstream fout("upsidedown.html");
if ( !fout )
return 2;
// go through input file, iterate through each line backwards,
// and call writeConvertedChar to put the upside down version of each
// character in
char buffer[BUFFERLENGTH];
while ( fin.getline(buffer, BUFFERLENGTH) )
{
cout << buffer << endl;
for (int i = getLength(buffer); i >= 0; i--)
writeConvertedChar( fout, buffer[i] );
fout << endl;
}
fin.close();
fout.close();
return 0;
}
This extremely exciting program allows me to be a prankster on message boards and post entire messages uʍop əpısdn.