请给段代码void CMyDlg::OnChangetianjiakuang() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
int IsGB(PTSTR pText) { unsigned char sqChar[20]; sqChar[0]=*pText; if (sqChar[0]>=0xa1) if (sqChar[0]==0xa3) return 1; //全角字符 else return 2; //汉字 else return 0; //英文、数字、英文标点 } 网上到处是!
IsDBCSLeadByte/IsDBCSLeadByteEx ------------------------------ IsDBCSLeadByte Determines if a specified character is potentially a lead byte. A lead byte is the first byte of a two-byte character in a double-byte character set (DBCS). Note: To use a different code page, your application should use the IsDBCSLeadByteEx function. BOOL IsDBCSLeadByte( BYTE TestChar ); Parameters TestChar [in] The character to test. Return Values Returns a nonzero value if the test character is potentially a lead byte.The function returns 0 if the test character is not a lead byte or if it is a single-byte character. To get extended error information, the application can call GetLastError.
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
{
unsigned char sqChar[20];
sqChar[0]=*pText;
if (sqChar[0]>=0xa1)
if (sqChar[0]==0xa3)
return 1; //全角字符
else
return 2; //汉字
else
return 0; //英文、数字、英文标点
} 网上到处是!
{
if((BYTE)Name[i] >= 0x80)
} 这样
// 首先调用GetDlgItem(),GetWindowText()从对话框中取出字符
char strText[100];
CString str;
GetDlgItem(IDC_EDIT1)->GetWindowText(str);
sprintf(strText,"%s", str);
const char *pS = strText; // 指向字符串
unsigned char strByte[2];
while(*pS)
{
strByte[0] = (unsigned char)*pS;
strByte[1] = (unsigned char)*(pS+1);
if( (strByte[0]>=0xa1 && strByte[0]<=0xfe)
&&(strByte[1]>=0xa1 && strByte[1]<=0xfe) )
{
//汉字
}
else
{
// ASCII
}
------------------------------
IsDBCSLeadByte
Determines if a specified character is potentially a lead byte. A lead byte is the first byte of a two-byte character in a double-byte character set (DBCS). Note: To use a different code page, your application should use the IsDBCSLeadByteEx function. BOOL IsDBCSLeadByte(
BYTE TestChar
);
Parameters
TestChar
[in] The character to test.
Return Values
Returns a nonzero value if the test character is potentially a lead byte.The function returns 0 if the test character is not a lead byte or if it is a single-byte character. To get extended error information, the application can call GetLastError.
char szText[10] = {0};
int nIndex = 0; for(size_t i=0; i != strlen(buf); ++i)
{
char ch = buf[i];
if(IsDBCSLeadByte(ch))
{
szText[nIndex++] = ch;
++i;
szText[nIndex++] = buf[i];
}
} CString strMsg(szText);
AfxMessageBox(strMsg);