bool IsHalfUnicode(CString strText)
{
const char* szStrText = (LPCTSTR)strText;
LPCTSTR p= szStrText;
int nCount = 0;
int nFonts = strText.GetLength();
int nUnicode = 0;
//是否为偶数个数
int nEven = nFonts%2;
bool bResult = false;
while( nFonts)
{
if( p[0] > 0 && p[0] <= 127)
{
if( p[0] >= 0x30 && p[0] <= 0x39)
{
//是数字
++nCount;
}
else if( (p[0] >= 0x41 && p[0] <= 0x5a) || (p[0] >= 0x61 && p[0] <= 0x7a) )
{
//是字母
++nCount;
}
}
//双字节
else
{
++nUnicode;
}
++p;
--nFonts;
}
//数据全部为ascil
if (nCount == nFonts)
{
bResult = true;
}
//数据全部为unicode
else if (nFonts == nUnicode)
{
if ( nEven != 0)
bResult = false;
}
//混合
else
{
if (nUnicode %2)
bResult = true;
}
return bResult;
}