判断是否是汉字

判断是否是汉字,只要满足任意一个(不完全正确)

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

RoutineCharacter Test Condition
isalnum, iswalnum, _ismbcalnumAlphanumeric
isalpha, iswalpha, _ismbcalphaAlphabetic
__isascii, iswasciiASCII
iscntrl, iswcntrlControl

isleadbyte

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值