例如:把“我们的祖国是花园”转变成为“wmdzgshy”
AnsiString ChineseToPY(AnsiString Chinese)
{
AnsiString tChinese,result="";
tChinese=Trim(Chinese);
AnsiString temp="";
char *ccp = new char[Chinese.Length()+1];
strcpy(ccp,tChinese.c_str());
for(int i=0;i<=tChinese.Length();i++)
{
if((WORD(WORD(ccp[i])<<8)>>8)>128) //判断是否为汉字
temp=temp+ccp[i++]+ccp[i];
}
char* cp = new char[temp.Length() + 1 ];
strcpy(cp,temp.c_str() );
for(int m=0;m<=temp.Length();m+=2)
{
int k;
k=(WORD(WORD(cp[m])<<8))+(WORD(WORD(cp[m+1])<<8)>>8);
if(k>=0xB0A1&&k<=0xB0C4)
result+="a";
if(k>=0xB0C5&&k<=0xB2C0)
result+="b";
if(k>=0xB2C1&&k<=0xB4ED)
result+="c";
if(k>=0xB4EE&&k<=0xB6E9)
result+="d";
if(k>=0xB6EA&&k<=0xB7A1)
result+="e";
if(k>=0xB7A2&&k<=0xB8C0)
result+="f";
if(k>=0xB8C1&&k<=0xB9FD)
result+="g";
if(k>=0xB9FE&&k<=0xBBF6)
result+="h";
if(k>=0xBBF7&&k<=0xBFA5)
result+="j";
if(k>=0xBFA6&&k<=0xC0AB)
result+="k";
if(k>=0xC0AC&&k<=0xC2E7)
result+="l";
if(k>=0xC2E8&&k<=0xC4C2)
result+="m";
if(k>=0xC4C3&&k<=0xC5B5)
result+="n";
if(k>=0xC5B6&&k<=0xC5BD)
result+="o";
if(k>=0xC5BE&&k<=0xC6D9)
result+="p";
if(k>=0xC6DA&&k<=0xC8BA)
result+="q";
if(k>=0xC8BB&&k<=0xC8F5)
result+="r";
if(k>=0xC8F6&&k<=0xCBF9)
result+="s";
if(k>=0xCBFA&&k<=0xCDD9)
result+="t";
if(k>=0xCDDA&&k<=0xCEF3)
result+="w";
if(k>=0xCEF4&&k<=0xD1B8)
result+="x";
if(k>=0xD1B9&&k<=0xD4D0)
result+="y";
if(k>=0xD4D1&&k<=0xD7F9)
result+="z";
}
return result;
}