Implementing an alphabet in c++

  alphabet, c++

I’m making a code for cipher that reads alphabet in it’s binary code. Is there a way to implement custom alphabet (not using ASCII)? For example alphabet={a,b,c,d,e,…,z,],[,.,…, ,-} and for each character there’s a number 0,1,…,63. So, the bijetion will be from element of alphabet to 6bit number. How to male this implementation using simple functions in c++?
I tried to make a strings length 1 and corresponding number using if statements and then plug them into .txt file, but it didn’t work out.

string str1,...,str63;
string sometext;
str1='a';
...
cin>>sometext;
int k;
k=sometext.length();
string res;
ofstream out;
out.open("cipher.txt");
for(int i=0;i<k;i++){
res=sometext.substr(i,1);
if(res==str1){res='000000';}
...
if(res==str63){res='111111';}
out<<res;
}

Source: Windows Questions C++

LEAVE A COMMENT