#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
void getWord(int, char**, char**);
void translateAndPrint(char*, ostream&);
int main(int argc, char** args)
{
char* word = new char[1024];
getWord(argc, args, &word);
fstream fileout;
fileout.open("out.txt", ios_base::out);
translateAndPrint(word, fileout);
//wchar_t x = 'ب';
//fileout << (char)x << endl;
fileout.flush();
fileout.close();
delete [] word;
system("pause");
return 0;
}
void translateAndPrint(char* word, ostream& out)
{
wchar_t map(char en);
while (*word != '\0')
{
out << (char)map(*word);
word++;
}
}
void getWord(int argc, char** args, char** word)
{
if (argc > 1)
strcpy(*word, args[1]);
else{
cout << "Enter an invalid word: " << endl;
*word = new char[1024];
cin.getline(*word, 1024);
}
}
wchar_t map(char en)
{
wchar_t ret;
switch(en)
{
default:
ret = en;
break;
case 'a':
ret = 'ش';
break;
case 'b':
ret = 'لا';
break;
case 'c':
ret = 'ؤ';
break;
case 'd':
ret = 'ي';
break;
case 'e':
ret = 'ث';
break;
case 'f':
ret = 'ب';
break;
case 'g':
ret = 'ل';
break;
case 'h':
ret = 'ا';
break;
case 'i':
ret = 'ه';
break;
case 'j':
ret = 'ت';
break;
case 'k':
ret = 'ن';
break;
case 'l':
ret = 'م';
break;
case 'm':
ret = 'ة';
break;
case 'n':
ret = 'ى';
break;
case 'o':
ret = 'خ';
break;
case 'p':
ret = 'ح';
break;
case 'q':
ret = 'ض';
break;
case 'r':
ret = 'ق';
break;
case 's':
ret = 'س';
break;
case 't':
ret = 'ف';
break;
case 'u':
ret = 'ع';
break;
case 'v':
ret = 'ر';
break;
case 'w':
ret = 'ص';
break;
case 'x':
ret = 'ء';
break;
case 'y':
ret = 'غ';
break;
case 'z':
ret = 'ئ';
break;
case ']':
ret = 'د';
break;
case '`':
ret = 'ذ';
break;
case ',':
ret = 'ظ';
break;
case '.':
ret = 'ظ';
break;
case '/':
ret = 'ظ';
break;
}
return ret;
}
25 June 2011
convert fault written arabic letters to English
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment