判断是否是汉字,只要满足任意一个(不完全正确)
int IsSimplifiedCH(BYTE lowbyte, BYTE highbyte)
{
int nRet;
//unsigned char highbyte;
//unsigned char lowbyte;
//highbyte = dch & 0x00ff;
//lowbyte = dch / 0x0100;
// 区名 码位范围 码位数 字符数 字符类型
// 双字节2区 B0A1—F7FE 6768 6763 汉字
if (
(highbyte >= 0xb0 && highbyte <= 0xf7) &&
(lowbyte >= 0xa1 && lowbyte <= 0xfe)
)
nRet = 1;
else
nRet = 0;
return nRet;
}
int IsGraphicCH(BYTE lowbyte, BYTE highbyte)
{
int nRet;
//unsigned char highbyte;
//unsigned char lowbyte;
//highbyte = dch & 0x00ff;
//lowbyte = dch / 0x0100;
// 区名 码位范围 码位数 字符数 字符类型
// 双字节1区 A1A1—A9FE 846 718 图形符号
if (
(highbyte >= 0xa1 && highbyte <= 0xa9) &&
(lowbyte >= 0xa1 && lowbyte <= 0xfe)
)
nRet = 1;
// 区名 码位范围 码位数 字符数 字符类型
// 双字节5区 A840—A9A0 192 166 图形符号
else if (
(highbyte >= 0xa8 && highbyte <= 0xa9) &&
(lowbyte >= 0x40 && lowbyte <= 0xa0)
)
nRet = 1;
else
nRet = 0;
return nRet;
}
还有 isprint(char ch),判断是否是可打印字符
等等
参考MSDN
----------------------------------------------
Character Classification
Each of these routines tests a specified single-byte character, wide character, or multibyte character for satisfaction of a condition. (By definition, the ASCII character set is a subset of all multibyte-character sets. For example, Japanese katakana includes ASCII as well as non-ASCII characters.) Generally these routines execute faster than tests you might write. For example, the following code executes slower than a call to isalpha(c):
if ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))
return TRUE;
Character-Classification Routines
Routine | Character Test Condition |
isalnum, iswalnum, _ismbcalnum | Alphanumeric |
isalpha, iswalpha, _ismbcalpha | Alphabetic |
__isascii, iswascii | ASCII |
iscntrl, iswcntrl | Control |
isleadbyte