ውክፔዲያ:String translation/Keyboard transliterator
Appearance
/******************************************************************************* * Amharic to english keyboard tranliterator. This program reads a mixture of * English and Amharic text from standard input and outputs English keyboard * transliteration of any embedded Amharic text. Each Amharic character is * represented by a small group of 1 to 5 characters seperated by spaces on * either side. Spaces in the original text are represented with a "~" in the * filtered text, and English text is repeated verbatim. *******************************************************************************/ #include <string.h> #include <iostream> using namespace std; int main() { const int BUF_SIZE = 1024; int letterValue; char buffer[BUF_SIZE]; bool amharicText = true; int i = 0; cout << "<Amharic> "; while(cin.good() && !cin.eof()) { memset(buffer, 0, BUF_SIZE); cin.getline(buffer, BUF_SIZE-3); i = 0; while(buffer[i] != 0 && i < BUF_SIZE-3) { letterValue = (int)buffer[i]; if(letterValue >= 0) { if(amharicText && letterValue != 32) { cout << "</Amharic>\n<English> "; amharicText = false; } switch(letterValue) { case 12: system("clear"); break; case 32: cout << "~ "; break; default: cout << (char)letterValue ; break; } } else { if(buffer[i+1] < 0 && buffer[i+2] < 0) { if(!amharicText) { cout << "</English>\n<Amharic> "; amharicText = true; } int total = buffer[i++] * 256 * 256; total += buffer[i++] * 256; total += buffer[i]; total *= -1; switch(total) { case 2062464: cout << "he" << " "; break; case 2062463: cout << "hu" << " "; break; case 2062462: cout << "hi" << " "; break; case 2062461: cout << "ha" << " "; break; case 2062460: cout << "hee" << " "; break; case 2062459: cout << "h" << " "; break; case 2062458: cout << "ho" << " "; break; case 2062456: cout << "le" << " "; break; case 2062455: cout << "lu" << " "; break; case 2062454: cout << "li" << " "; break; case 2062453: cout << "la" << " "; break; case 2062452: cout << "lee" << " "; break; case 2062451: cout << "l" << " "; break; case 2062450: cout << "lo" << " "; break; case 2062449: cout << "lwwa" << " "; break; case 2062448: cout << "He" << " "; break; case 2062447: cout << "Hu" << " "; break; case 2062446: cout << "Hi" << " "; break; case 2062445: cout << "Ha" << " "; break; case 2062444: cout << "Hee" << " "; break; case 2062443: cout << "H" << " "; break; case 2062442: cout << "Ho" << " "; break; case 2062441: cout << "Hwwa" << " "; break; case 2062440: cout << "me" << " "; break; case 2062439: cout << "mu" << " "; break; case 2062438: cout << "mi" << " "; break; case 2062437: cout << "ma" << " "; break; case 2062436: cout << "mee" << " "; break; case 2062435: cout << "m" << " "; break; case 2062434: cout << "mo" << " "; break; case 2062433: cout << "mwwa" << " "; break; case 2062432: cout << "sse" << " "; break; case 2062431: cout << "ssu" << " "; break; case 2062430: cout << "ssi" << " "; break; case 2062429: cout << "ssa" << " "; break; case 2062428: cout << "ssee" << " "; break; case 2062427: cout << "ss" << " "; break; case 2062426: cout << "sso" << " "; break; case 2062425: cout << "ssWa" << " "; break; case 2062424: cout << "re" << " "; break; case 2062423: cout << "ru" << " "; break; case 2062422: cout << "ri" << " "; break; case 2062421: cout << "ra" << " "; break; case 2062420: cout << "ree" << " "; break; case 2062419: cout << "r" << " "; break; case 2062418: cout << "ro" << " "; break; case 2062417: cout << "rwwa" << " "; break; case 2062416: cout << "se" << " "; break; case 2062415: cout << "su" << " "; break; case 2062414: cout << "si" << " "; break; case 2062413: cout << "sa" << " "; break; case 2062412: cout << "see" << " "; break; case 2062411: cout << "s" << " "; break; case 2062410: cout << "so" << " "; break; case 2062409: cout << "swwa" << " "; break; case 2062408: cout << "xe" << " "; break; case 2062407: cout << "xu" << " "; break; case 2062406: cout << "xi" << " "; break; case 2062405: cout << "xa" << " "; break; case 2062404: cout << "xee" << " "; break; case 2062403: cout << "x" << " "; break; case 2062402: cout << "xo" << " "; break; case 2062401: cout << "twwa" << " "; break; case 2062208: cout << "qe" << " "; break; case 2062207: cout << "qu" << " "; break; case 2062206: cout << "qi" << " "; break; case 2062205: cout << "qa" << " "; break; case 2062204: cout << "qee" << " "; break; case 2062203: cout << "q" << " "; break; case 2062202: cout << "qo" << " "; break; case 2062200: cout << "qwwe" << " "; break; //case 2062199: cout << "qwwi" << " "; break; case 2062198: cout << "qwwi" << " "; break; case 2062197: cout << "qwwa" << " "; break; case 2062196: cout << "qwwee" << " "; break; case 2062195: cout << "qwwu" << " "; break; case 2062192: cout << "Qe" << " "; break; case 2062191: cout << "Qu" << " "; break; case 2062190: cout << "Qi" << " "; break; case 2062189: cout << "Qa" << " "; break; case 2062188: cout << "Qee" << " "; break; case 2062187: cout << "Q" << " "; break; case 2062186: cout << "Qo" << " "; break; case 2062184: cout << "Qwwe" << " "; break; case 2062182: cout << "Qwwi" << " "; break; case 2062181: cout << "Qwwa" << " "; break; case 2062180: cout << "Qwwee" << " "; break; case 2062179: cout << "Qwwu" << " "; break; case 2062176: cout << "be" << " "; break; case 2062175: cout << "bu" << " "; break; case 2062174: cout << "bi" << " "; break; case 2062173: cout << "ba" << " "; break; case 2062172: cout << "bee" << " "; break; case 2062171: cout << "b" << " "; break; case 2062170: cout << "bo" << " "; break; case 2062169: cout << "bwwa" << " "; break; case 2062168: cout << "ve" << " "; break; case 2062167: cout << "vu" << " "; break; case 2062166: cout << "vi" << " "; break; case 2062165: cout << "va" << " "; break; case 2062164: cout << "vee" << " "; break; case 2062163: cout << "v" << " "; break; case 2062162: cout << "vo" << " "; break; case 2062161: cout << "vwwa" << " "; break; case 2062160: cout << "te" << " "; break; case 2062159: cout << "tu" << " "; break; case 2062158: cout << "ti" << " "; break; case 2062157: cout << "ta" << " "; break; case 2062156: cout << "tee" << " "; break; case 2062155: cout << "t" << " "; break; case 2062154: cout << "to" << " "; break; case 2062153: cout << "twwa" << " "; break; case 2062152: cout << "ce" << " "; break; case 2062151: cout << "cu" << " "; break; case 2062150: cout << "ci" << " "; break; case 2062149: cout << "ca" << " "; break; case 2062148: cout << "cee" << " "; break; case 2062147: cout << "c" << " "; break; case 2062146: cout << "co" << " "; break; case 2062145: cout << "cwwa" << " "; break; case 2061952: cout << "hhe" << " "; break; case 2061951: cout << "hhu" << " "; break; case 2061950: cout << "hhi" << " "; break; case 2061949: cout << "hha" << " "; break; case 2061948: cout << "hhee" << " "; break; case 2061947: cout << "hh" << " "; break; case 2061946: cout << "hho" << " "; break; case 2061944: cout << "hwwe" << " "; break; case 2061942: cout << "hwwi" << " "; break; case 2061941: cout << "hwwa" << " "; break; case 2061940: cout << "hwwee" << " "; break; case 2061939: cout << "hwwu" << " "; break; case 2061936: cout << "ne" << " "; break; case 2061935: cout << "nu" << " "; break; case 2061934: cout << "ni" << " "; break; case 2061933: cout << "na" << " "; break; case 2061932: cout << "nee" << " "; break; case 2061931: cout << "n" << " "; break; case 2061930: cout << "no" << " "; break; case 2061929: cout << "nwwa" << " "; break; case 2061928: cout << "Ne" << " "; break; case 2061927: cout << "Nu" << " "; break; case 2061926: cout << "Ni" << " "; break; case 2061925: cout << "Na" << " "; break; case 2061924: cout << "Nee" << " "; break; case 2061923: cout << "N" << " "; break; case 2061922: cout << "No" << " "; break; case 2061921: cout << "Nwwa" << " "; break; case 2061920: cout << "a" << " "; break; case 2061919: cout << "u" << " "; break; case 2061918: cout << "i" << " "; break; case 2061917: cout << "A" << " "; break; case 2061916: cout << "E" << " "; break; case 2061915: cout << "e" << " "; break; case 2061914: cout << "o" << " "; break; case 2061913: cout << "eW" << " "; break; case 2061912: cout << "ke" << " "; break; case 2061911: cout << "ku" << " "; break; case 2061910: cout << "ki" << " "; break; case 2061909: cout << "ka" << " "; break; case 2061908: cout << "kee" << " "; break; case 2061907: cout << "k" << " "; break; case 2061906: cout << "ko" << " "; break; case 2061905: cout << "1" << " "; break; case 2061904: cout << "kwwe" << " "; break; case 2061903: cout << "3" << " "; break; case 2061902: cout << "kwwi" << " "; break; case 2061901: cout << "kwwa" << " "; break; case 2061900: cout << "kwwee" << " "; break; case 2061899: cout << "kwwu" << " "; break; case 2061896: cout << "Ke" << " "; break; case 2061895: cout << "Ku" << " "; break; case 2061894: cout << "Ki" << " "; break; case 2061893: cout << "Ka" << " "; break; case 2061892: cout << "Kee" << " "; break; case 2061891: cout << "K" << " "; break; case 2061890: cout << "Ko" << " "; break; case 2061696: cout << "Kwwe" << " "; break; case 2061694: cout << "Kwwi" << " "; break; case 2061693: cout << "Kwwa" << " "; break; case 2061692: cout << "Kwwee" << " "; break; case 2061691: cout << "Kwwu" << " "; break; case 2061688: cout << "we" << " "; break; case 2061687: cout << "wu" << " "; break; case 2061686: cout << "wi" << " "; break; case 2061685: cout << "wa" << " "; break; case 2061684: cout << "wee" << " "; break; case 2061683: cout << "w" << " "; break; case 2061682: cout << "wo" << " "; break; case 2061680: cout << "eee" << " "; break; case 2061679: cout << "uu" << " "; break; case 2061678: cout << "ii" << " "; break; case 2061677: cout << "aa" << " "; break; case 2061676: cout << "EE" << " "; break; case 2061675: cout << "ee" << " "; break; case 2061674: cout << "oo" << " "; break; case 2061672: cout << "ze" << " "; break; case 2061671: cout << "zu" << " "; break; case 2061670: cout << "zi" << " "; break; case 2061669: cout << "za" << " "; break; case 2061668: cout << "zee" << " "; break; case 2061667: cout << "z" << " "; break; case 2061666: cout << "zo" << " "; break; case 2061665: cout << "zwwa" << " "; break; case 2061664: cout << "Ze" << " "; break; case 2061663: cout << "Zu" << " "; break; case 2061662: cout << "Zi" << " "; break; case 2061661: cout << "Za" << " "; break; case 2061660: cout << "Zee" << " "; break; case 2061659: cout << "Z" << " "; break; case 2061658: cout << "Zo" << " "; break; case 2061657: cout << "Zwwa" << " "; break; case 2061656: cout << "ye" << " "; break; case 2061655: cout << "yu" << " "; break; case 2061654: cout << "yi" << " "; break; case 2061653: cout << "ya" << " "; break; case 2061652: cout << "yee" << " "; break; case 2061651: cout << "y" << " "; break; case 2061650: cout << "yo" << " "; break; case 2061648: cout << "de" << " "; break; case 2061647: cout << "du" << " "; break; case 2061646: cout << "di" << " "; break; case 2061645: cout << "da" << " "; break; case 2061644: cout << "dee" << " "; break; case 2061643: cout << "d" << " "; break; case 2061642: cout << "do" << " "; break; case 2061641: cout << "dwwa" << " "; break; case 2061640: cout << "De" << " "; break; case 2061639: cout << "Du" << " "; break; case 2061638: cout << "Di" << " "; break; case 2061637: cout << "Da" << " "; break; case 2061636: cout << "Dee" << " "; break; case 2061635: cout << "D" << " "; break; case 2061634: cout << "Do" << " "; break; case 2061633: cout << "Dwwa" << " "; break; case 2061440: cout << "je" << " "; break; case 2061439: cout << "ju" << " "; break; case 2061438: cout << "ji" << " "; break; case 2061437: cout << "ja" << " "; break; case 2061436: cout << "jee" << " "; break; case 2061435: cout << "j" << " "; break; case 2061434: cout << "jo" << " "; break; case 2061433: cout << "jwwa" << " "; break; case 2061432: cout << "ge" << " "; break; case 2061431: cout << "gu" << " "; break; case 2061430: cout << "gi" << " "; break; case 2061429: cout << "ga" << " "; break; case 2061428: cout << "gee" << " "; break; case 2061427: cout << "g" << " "; break; case 2061426: cout << "go" << " "; break; case 2061424: cout << "gwwe" << " "; break; case 2061422: cout << "gwwi" << " "; break; case 2061421: cout << "gwwa" << " "; break; case 2061420: cout << "gwwee" << " "; break; case 2061419: cout << "gwwu" << " "; break; case 2061416: cout << "Ge" << " "; break; case 2061415: cout << "Gu" << " "; break; case 2061414: cout << "Gi" << " "; break; case 2061413: cout << "Ga" << " "; break; case 2061412: cout << "Gee" << " "; break; case 2061411: cout << "G" << " "; break; case 2061410: cout << "Go" << " "; break; case 2061408: cout << "Te" << " "; break; case 2061407: cout << "Tu" << " "; break; case 2061406: cout << "Ti" << " "; break; case 2061405: cout << "Ta" << " "; break; case 2061404: cout << "Tee" << " "; break; case 2061403: cout << "T" << " "; break; case 2061402: cout << "To" << " "; break; case 2061401: cout << "Twwa" << " "; break; case 2061400: cout << "Ce" << " "; break; case 2061399: cout << "Cu" << " "; break; case 2061398: cout << "Ci" << " "; break; case 2061397: cout << "Ca" << " "; break; case 2061396: cout << "Cee" << " "; break; case 2061395: cout << "C" << " "; break; case 2061394: cout << "Co" << " "; break; case 2061393: cout << "Cwwa" << " "; break; case 2061392: cout << "Pe" << " "; break; case 2061391: cout << "Pu" << " "; break; case 2061390: cout << "Pi" << " "; break; case 2061389: cout << "Pa" << " "; break; case 2061388: cout << "Pee" << " "; break; case 2061387: cout << "P" << " "; break; case 2061386: cout << "Po" << " "; break; case 2061385: cout << "Pwwa" << " "; break; case 2061384: cout << "Se" << " "; break; case 2061383: cout << "Su" << " "; break; case 2061382: cout << "Si" << " "; break; case 2061381: cout << "Sa" << " "; break; case 2061380: cout << "See" << " "; break; case 2061379: cout << "S" << " "; break; case 2061378: cout << "So" << " "; break; case 2061377: cout << "Swwa" << " "; break; case 2061184: cout << "SSe" << " "; break; case 2061183: cout << "SSu" << " "; break; case 2061182: cout << "SSi" << " "; break; case 2061181: cout << "SSa" << " "; break; case 2061180: cout << "SSee" << " "; break; case 2061179: cout << "SS" << " "; break; case 2061178: cout << "SSo" << " "; break; case 2061176: cout << "fe" << " "; break; case 2061175: cout << "fu" << " "; break; case 2061174: cout << "fi" << " "; break; case 2061173: cout << "fa" << " "; break; case 2061172: cout << "fee" << " "; break; case 2061171: cout << "f" << " "; break; case 2061170: cout << "fo" << " "; break; case 2061169: cout << "fwwa" << " "; break; case 2061168: cout << "pe" << " "; break; case 2061167: cout << "pu" << " "; break; case 2061166: cout << "pi" << " "; break; case 2061165: cout << "pa" << " "; break; case 2061164: cout << "pee" << " "; break; case 2061163: cout << "p" << " "; break; case 2061162: cout << "po" << " "; break; case 2061161: cout << "pwwa" << " "; break; case 2061151: cout << ":" << " "; break; case 2061150: cout << "::" << " "; break; case 2061149: cout << "," << " "; break; case 2061148: cout << ";" << " "; break; case 2061147: cout << ",," << " "; break; case 2061146: cout << ":-" << " "; break; case 2061145: cout << "??" << " "; break; case 2061144: cout << ":|:" << " "; break; default: cerr << "\nUnkown character: " << total; break; } } } i++; } } if(amharicText) { cout << "</Amharic>\n"; } else { cout << "</English>\n"; } return 0; }