#include "StdAfx.h"
#include "MyChiToLetter.h"
// Download by http://www.codefans.net
CMyChiToLetter::CMyChiToLetter()
{
m_blnSimaple=FALSE;
m_blnFirstBig=TRUE;
m_blnAllBiG=TRUE;
m_LetterEnd=FALSE;
}
CMyChiToLetter::~CMyChiToLetter()
{
}
CSPString CMyChiToLetter::GetLetter(CSPString strText)
{
TBYTE ucHigh, ucLow;
int nCode,j;
CSPString strValue="";
for (int i=0; i<strText.GetLength(); i++)
{
if ( (TBYTE)strText[i] < 0x80 )
{
strValue=strValue+_T(strText[i]);
if(m_LetterEnd) strValue=strValue+_T('\'');
continue;
}
ucHigh = (TBYTE)strText[i];
ucLow = (TBYTE)strText[i+1];
if ( ucHigh < 0xa1 || ucLow < 0xa1)
continue;
else if(ucHigh==163) // 全角字符
{
char ch = ucLow-128;
strValue=strValue+CSPString(ch);
}
else if(ucHigh==161) // 全角字符
{
char ch;
if(ucLow == 171)
ch = '~';
else if(ucLow == 231)
ch = '$';
else if(ucLow == 161)
ch = ' ';
else
ch = ucLow-151;
strValue=strValue+CSPString(ch);
}
else if(ucHigh==166) // 全角字符
{
char ch = ucLow-134;
strValue=strValue+CSPString(ch);
}
else
{
nCode = (ucHigh - 0xa0) * 100 + ucLow - 0xa0;
CSPString strRes=_T(FindLetter(nCode));
if(m_blnSimaple&&strRes.GetLength()>0)
{
strRes=strRes.Left(1);
}
if(!m_blnFirstBig)
{
strRes.SetAt(0,strRes.GetAt(0)+32);
}
if(!m_blnAllBiG)
{
for(j=1;j<strRes.GetLength();j++)
{
strRes.SetAt(j,(strRes.GetAt(j)+32));
}
}
strValue=strValue+strRes;
}
i++;
if(m_LetterEnd) strValue=strValue+_T('\'');
}
return strValue;
}
CSPString CMyChiToLetter::FindLetter(int nCode)
{
CSPString strValue;
switch(nCode)
{
case 6325:
case 6436:
case 7571:
case 7925:
strValue="A";
break;
case 6263:
case 6440:
case 7040:
case 7208:
case 7451:
case 7733:
case 7945:
case 8616:
strValue="AI";
break;
case 5847:
case 5991:
case 6278:
case 6577:
case 6654:
case 7281:
case 7907:
case 8038:
case 8786:
strValue="AN";
break;
strValue="ANG";
break;
case 5974:
case 6254:
case 6427:
case 6514:
case 6658:
case 6959:
case 7033:
case 7081:
case 7365:
case 8190:
case 8292:
case 8643:
case 8701:
case 8773:
strValue="AO";
break;
case 6056:
case 6135:
case 6517:
case 7857:
case 8446:
case 8649:
case 8741:
strValue="BA";
break;
case 6267:
case 6334:
case 7494:
strValue="BAI";
break;
case 5870:
case 5964:
case 7851:
case 8103:
case 8113:
case 8418:
strValue="BAN";
break;
case 6182:
case 6826:
strValue="BANG";
break;
case 6165:
case 7063:
case 7650:
case 8017:
case 8157:
case 8532:
case 8621:
strValue="BAO";
break;
case 5635:
case 5873:
case 5893:
case 5993:
case 6141:
case 6703:
case 7753:
case 8039:
case 8156:
case 8645:
case 8725:
strValue="BEI";
break;
case 5946:
case 5948:
case 7458:
case 7928:
strValue="BEN";
break;
case 6452:
case 7420:
strValue="BENG";
break;
case 5616:
case 5734:
case 6074:
case 6109:
case 6221:
case 6333:
case 6357:
case 6589:
case 6656:
case 6725:
case 6868:
case 6908:
case 6986:
case 6994:
case 7030:
case 7052:
case 7221:
case 7815:
case 7873:
case 7985:
case 8152:
case 8357:
case 8375:
case 8387:
case 8416:
case 8437:
case 8547:
case 8734:
strValue="BI";
break;
case 5650:
case 5945:
case 6048:
case 6677:
case 6774:
case 7134:
case 7614:
case 7652:
case 7730:
case 7760:
case 8125:
case 8159:
case 8289:
case 8354:
case 8693:
strValue="BIAN";
break;
case 7027:
case 7084:
case 7609:
case 7613:
case 7958:
case 7980:
case 8106:
case 8149:
case 8707:
case 8752:
strValue="BIAO";
break;
case 8531:
strValue="BIE";
break;
case 5747:
case 6557:
case 7145:
case 7167:
case 7336:
case 7375:
case 7587:
case 7957:
case 8738:
case 8762:
strValue="BIN";
break;
case 5787:
case 5891:
case 6280:
strValue="BING";
break;
case 5781:
case 6403:
case 6636:
case 7362:
case 7502:
case 7771:
case 7864:
case 8030:
case 8404:
case 8543:
case 8559:
strValue="BO";
break;
case 6318:
case 6945:
case 7419:
case 7446:
case 7848:
case 7863:
case 8519:
strValue="BU";
break;
case 6474:
case 7769:
strValue="CA";
break;
strValue="CAI";
break;
case 6978:
case 7078:
case 7218:
case 8451:
case 8785:
strValue="CAN";
break;
case 5687:
strValue="CANG";
break;
case 6448:
case 6878:
case 8309:
case 8429:
strValue="CAO";
break;
case 6692:
strValue="CE";
break;
case 6515:
case 6825:
strValue="CEN";
break;
case 6465:
strValue="CENG";
break;
case 6639:
case 6766:
case 7017:
case 7230:
case 7311:
case 7322:
case 7363:
case 7942:
case 7979:
case 8135:
strValue="CHA";
break;
case 5713:
case 7846:
case 8091:
case 8218:
strValue="CHAI";
break;
case 5770:
case 5838:
case 6159:
case 6667:
case 6893:
case 6904:
case 6981:
case 7031:
case 7086:
case 7472:
case 7688:
case 7966:
case 8324:
case 8580:
strValue="CHAN";
break;
case 5686:
case 5943:
case 6041:
case 6137:
case 6660:
case 6568:
case 6749:
case 7029:
case 7047:
case 7438:
case 7509:
case 8680:
strValue="CHANG";
break;
case 6687:
case 7443:
case 8173:
strValue="CHAO";
break;
case 5969:
case 7726:
strValue="CHE";
break;
case 5840:
case 5863:
case 6251:
case 6433:
case 6923:
case 7201:
case 7320:
case 7755:
case 8619:
strValue="CHEN";
break;
case 5609:
case 5984:
case 7239:
case 7263:
case 7583:
case 7810:
case 7881:
case 7905:
case 8146:
case 8241:
case 8508:
strValue="CHENG";
break;
case 5749:
case 6015:
case 6061:
case 6319:
case 6374:
case 6420:
case 6445:
case 6633:
case 7042:
case 7523:
case 7787:
case 8023:
case 8101:
case 8161:
case 8231:
case 8304:
case 8355:
case 8388:
case 8489:
case 8556:
case 8746:
strValue="CHI";
break;
case 6091:
case 6671:
case 6731:
case 8409:
case 8430:
strValue="CHONG";
break;
case 5717:
case 6492:
case 6716:
case 8112:
case 8637:
strValue="CHOU";
break;
case 5601:
case 5927:
case 6680:
case 6732:
case 7109:
case 7238:
case 7290:
case 7343:
case 8150:
case 8260:
case 8573:
case 8777:
strValue="CHU";
break;
case 6285:
case 6408:
case 7590:
case 8563:
strValue="CHUAI";
break;
case 6622:
case 6955:
case 7516:
case 7843:
case 8413:
strValue="CHUAN";
break;
case 6675:
strValue="CHUANG";
break;
case 5879:
case 7302:
case 7319:
strValue="CHUI";
break;
case 6127:
case 8040:
case 8277:
strValue="CHUN";
break;
case 7401:
case 8554:
case 8626:
strValue="CHUO";
break;
strValue="CI";
break;
case 6075:
case 6358:
case 7684:
case 8043:
case 8457:
strValue="4337 伺";
break;
case 6042:
case 6840:
case 7085:
case 7193:
case 7214:
case 7240:
strValue="CONG";
break;
case 7308:
case 7403:
case 7577:
strValue="COU";
break;
case 6180:
case 6562:
case 6607:
case 7367:
case 8501:
case 8530:
case 8577:
strValue="CU";
break;
case 5764:
case 6305:
case 7664:
case 7973:
strValue="CUAN";
break;
case 6718:
case 6145:
case 6393:
case 7213:
case 7333:
case 7505:
case 8631:
strValue="CUI";
break;
case 6666:
case 8169:
strValue="CUN";
break;
case 5640:
case 6547:
case 7566:
case 7917:
case 7983:
case 8078:
case 8526:
case 8567:
strValue="CUO";