字符分类Character Classification

其中的每个例程均针对条件满意度测试指定的单字节字符、宽字符或多字节字符。Each of these routines tests a specified single-byte character, wide character, or multibyte character for satisfaction of a condition. (根据定义,0 和 127 之间的 ASCII 字符集是所有多字节字符集的子集。(By definition, the ASCII character set between 0 and 127 are a subset of all multibyte-character sets. 例如,日语的片假名包括 ASCII 以及非 ASCII 字符。)For example, Japanese katakana includes ASCII as well as non-ASCII characters.)

测试条件受区域设置的 LC_CTYPE 类别设置影响;有关详细信息,请参阅 setlocaleThe test conditions are affected by the setting of the LC_CTYPE category setting of the locale; see setlocale for more information. 这些不带 _l 后缀的函数的版本使用为该区域设置相关的行为的当前区域设置;带有 _l 后缀的版本相同,只不过它们使用传递的区域设置参数。The versions of these functions without the _l suffix use the current locale for this locale-dependent behavior; the versions with the _l suffix are identical except that they use the locale parameter passed in instead.

与你可能编写的测试相比,这些例程的执行速度通常更快,因此应优先考虑。Generally these routines execute faster than tests you might write and should be favored over. 例如,以下代码执行速度慢于调用 isalpha(c)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、_isalnum_l、_iswalnum_lisalnum、iswalnum、_isalnum_l、_iswalnum_lisalnum, iswalnum, _isalnum_l, _iswalnum_l, _ismbcalnum, _ismbcalnum_l, _ismbcalpha, _ismbcalpha_l, _ismbcdigit, _ismbcdigit_l 字母数字Alphanumeric
_ismbcalnum、_ismbcalnum_l、_ismbcalpha、_ismbcalpha_l、_ismbcdigit、_ismbcdigit_l_ismbcalnum, _ismbcalnum_l, _ismbcalpha, _ismbcalpha_l, _ismbcdigit, _ismbcdigit_l 字母数字Alphanumeric
isalpha、iswalpha、_isalpha_l、_iswalpha_lisalnum、iswalnum、_isalnum_l、_iswalnum_lisalpha, iswalpha, _isalpha_l, _iswalpha_l, _ismbcalnum, _ismbcalnum_l, _ismbcalpha, _ismbcalpha_l, _ismbcdigit, _ismbcdigit_l AlphabeticAlphabetic
isascii、__isascii、iswasciiisascii, __isascii, iswascii ASCIIASCII
isblank、iswblank、_isblank_l、_iswblank_l_ismbcsblank、_ismbcsblank_lisblank, iswblank, _isblank_l, _iswblank_l, _ismbcsblank, _ismbcsblank_l 空白(空格或水平制表符)Blank (space or horizontal tab)
iscntrl、iswcntrl、_iscntrl_l、_iswcntrl_liscntrl, iswcntrl, _iscntrl_l, _iswcntrl_l 控件Control
iscsym、iscsymf、__iscsym、___iswcsym、___iscsymf、___iswcsymf、_iscsym_l、_iswcsym_l、_iscsymf_l、_iswcsymf_liscsym, iscsymf, __iscsym, __iswcsym, __iscsymf, __iswcsymf, _iscsym_l, _iswcsym_l, _iscsymf_l, _iswcsymf_l 字母、下划线或数字Letter, underscore, or digit
iscsym、iscsymf、__iscsym、___iswcsym、___iscsymf、___iswcsymf、_iscsym_l、_iswcsym_l、_iscsymf_l、_iswcsymf_liscsym, iscsymf, __iscsym, __iswcsym, __iscsymf, __iswcsymf, _iscsym_l, _iswcsym_l, _iscsymf_l, _iswcsymf_l 字母或下划线Letter or underscore
isdigit、iswdigit、_isdigit_l、_iswdigit_lisalnum、iswalnum、_isalnum_l、_iswalnum_lisdigit, iswdigit, _isdigit_l, _iswdigit_l, _ismbcalnum, _ismbcalnum_l, _ismbcalpha, _ismbcalpha_l, _ismbcdigit, _ismbcdigit_l 十进制数字Decimal digit
isgraph、iswgraph、_isgraph_l、_iswgraph_l_ismbcgraph、_ismbcgraph_l、_ismbcprint、_ismbcprint_l、_ismbcpunct、_ismbcpunct_l、_ismbcblank、_ismbcblank_l、_ismbcspace、_ismbcspace_lisgraph, iswgraph, _isgraph_l, _iswgraph_l, _ismbcgraph, _ismbcgraph_l, _ismbcprint, _ismbcprint_l, _ismbcpunct, _ismbcpunct_l, _ismbcblank, _ismbcblank_l, _ismbcspace, _ismbcspace_l 可打印(空格除外)Printable other than space
islower、iswlower、_islower_l、_iswlower_l_ismbclower、_ismbclower_l、_ismbcupper、_ismbcupper_lislower, iswlower, _islower_l, _iswlower_l, _ismbclower, _ismbclower_l, _ismbcupper, _ismbcupper_l 小写Lowercase
_ismbchira、_ismbchira_l、_ismbckata、_ismbckata_l_ismbchira, _ismbchira_l, _ismbckata, _ismbckata_l 平假名Hiragana
_ismbchira、_ismbchira_l、_ismbckata、_ismbckata_l_ismbchira, _ismbchira_l, _ismbckata, _ismbckata_l 片假名Katakana
_ismbclegal、_ismbclegal_l、_ismbcsymbol、_ismbcsymbol_l_ismbclegal, _ismbclegal_l, _ismbcsymbol, _ismbcsymbol_l 有效的多字节字符Legal multibyte character
_ismbcl0、_ismbcl0_l、_ismbcl1、_ismbcl1_l、_ismbcl2、_ismbcl2_l_ismbcl0, _ismbcl0_l, _ismbcl1, _ismbcl1_l, _ismbcl2, _ismbcl2_l 日本 0 级多字节字符Japan-level 0 multibyte character
_ismbcl0、_ismbcl0_l、_ismbcl1、_ismbcl1_l、_ismbcl2、_ismbcl2_l_ismbcl0, _ismbcl0_l, _ismbcl1, _ismbcl1_l, _ismbcl2, _ismbcl2_l 日本 1 级多字节字符Japan-level 1 multibyte character
_ismbcl0、_ismbcl0_l、_ismbcl1、_ismbcl1_l、_ismbcl2、_ismbcl2_l_ismbcl0, _ismbcl0_l, _ismbcl1, _ismbcl1_l, _ismbcl2, _ismbcl2_l 日本 2 级多字节字符Japan-level 2 multibyte character
_ismbclegal、_ismbclegal_l、_ismbcsymbol、_ismbcsymbol_l_ismbclegal, _ismbclegal_l, _ismbcsymbol, _ismbcsymbol_l 非字母数字的多字节字符Non-alphanumeric multibyte character
isprint、iswprint、_isprint_l、_iswprint_l_ismbcgraph、_ismbcgraph_l、_ismbcprint、_ismbcprint_l、_ismbcpunct、_ismbcpunct_l、_ismbcblank、_ismbcblank_l、_ismbcspace、_ismbcspace_lisprint, iswprint, _isprint_l, _iswprint_l, _ismbcgraph, _ismbcgraph_l, _ismbcprint, _ismbcprint_l, _ismbcpunct, _ismbcpunct_l, _ismbcblank, _ismbcblank_l, _ismbcspace, _ismbcspace_l 可打印Printable
ispunct、iswpunct、_ispunct_l、_iswpunct_l_ismbcgraph、_ismbcgraph_l、_ismbcprint、_ismbcprint_l、_ismbcpunct、_ismbcpunct_l、_ismbcblank、_ismbcblank_l、_ismbcspace、_ismbcspace_lispunct, iswpunct, _ispunct_l, _iswpunct_l, _ismbcgraph, _ismbcgraph_l, _ismbcprint, _ismbcprint_l, _ismbcpunct, _ismbcpunct_l, _ismbcblank, _ismbcblank_l, _ismbcspace, _ismbcspace_l 标点Punctuation
isspace、iswspace、_isspace_l、_iswspace_l_ismbcgraph、_ismbcgraph_l、_ismbcprint、_ismbcprint_l、_ismbcpunct、_ismbcpunct_l、_ismbcblank、_ismbcblank_l、_ismbcspace、_ismbcspace_lisspace, iswspace, _isspace_l, _iswspace_l, _ismbcgraph, _ismbcgraph_l, _ismbcprint, _ismbcprint_l, _ismbcpunct, _ismbcpunct_l, _ismbcblank, _ismbcblank_l, _ismbcspace, _ismbcspace_l 空格White-space
Isupper、iswupper, _ismbclower、_ismbclower_l、_ismbcupper、_ismbcupper_lIsupper, iswupper, _ismbclower, _ismbclower_l, _ismbcupper, _ismbcupper_l 大写Uppercase
_isctype、iswctype、_isctype_l、_iswctype_l_isctype, iswctype, _isctype_l, _iswctype_l desc 参数指定的属性Property specified by desc argument
isxdigit、iswxdigit、_isxdigit_l、_iswxdigit_lisxdigit, iswxdigit, _isxdigit_l, _iswxdigit_l 十六进制数Hexadecimal digit
_mbclen、mblen、_mblen_l_mbclen, mblen, _mblen_l 返回有效的多字节字符的长度;结果取决于当前区域设置的 LC_CTYPE 类别设置Return length of valid multibyte character; result depends on LC_CTYPE category setting of current locale

另请参阅See Also

按类别分的运行时例程Run-Time Routines by Category