<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Ctype.h</id>
	<title>Ctype.h - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Ctype.h"/>
	<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Ctype.h&amp;action=history"/>
	<updated>2026-07-06T01:47:21Z</updated>
	<subtitle>在这个wiki上该页的修订历史</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://arolstar52-zhtest.hf.space/index.php?title=Ctype.h&amp;diff=2150621&amp;oldid=prev</id>
		<title>imported&gt;InternetArchiveBot：​补救1个来源，并将0个来源标记为失效。) #IABot (v2.0.7</title>
		<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Ctype.h&amp;diff=2150621&amp;oldid=prev"/>
		<updated>2020-09-25T12:41:24Z</updated>

		<summary type="html">&lt;p&gt;补救1个来源，并将0个来源标记为失效。) #IABot (v2.0.7&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{noteTA&lt;br /&gt;
|G1=IT&lt;br /&gt;
|1=zh-hans:宏; zh-hant:巨集;&lt;br /&gt;
}}&lt;br /&gt;
{{lowercase|title=ctype.h}}&lt;br /&gt;
{{C_Standard_library}} &amp;lt;!-- to edit this template go to [[template:C_Standard_library]] --&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;ctype.h&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039;是[[C標準函数庫]]中的[[头文件]]，定义了一批[[C语言]]字符分类函数（C character classification functions），用于测试字符是否属于特定的字符类别，如字母字符、控制字符等等。既支持单字节字符，也支持[[宽字符]]。&amp;lt;ref&amp;gt;{{cite book  | url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf  | title=ISO/IEC 9899:1999 specification  | at=p. 193, § 7.4  | access-date=2013-06-20  | archive-date=2011-01-24  | archive-url=https://web.archive.org/web/20110124052108/http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf  | dead-url=yes  }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
== 实现 ==&lt;br /&gt;
现代的C库中，字符分类函数一般不用比较测试（comparison tests）实现，而是静态查表来实现。&lt;br /&gt;
&lt;br /&gt;
例如，创建一个由256个8位宽整数组成的数组，每个整数的每位对应字符的特定的分类性质，如属于数字、属于字母等等。如果最低位表示属于数字性质，那么可以写成如下代码：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;#define isdigit(x) (TABLE[x] &amp;amp; 1)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
早期版本的[[Linux]]使用了潜在犯错的方法，类似于：&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;#define isdigit(x) ((x) &amp;gt;= &amp;#039;0&amp;#039; &amp;amp;&amp;amp; (x) &amp;lt;= &amp;#039;9&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
这会产生问题，如宏参数&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;具有[[函数副作用|副作用]]---例如，如果调用&amp;lt;code&amp;gt;isdigit(x++)&amp;lt;/code&amp;gt;或&amp;lt;code&amp;gt;isdigit(run_some_program())&amp;lt;/code&amp;gt;，可能不是很显然，&amp;lt;code&amp;gt;isdigit&amp;lt;/code&amp;gt;的参数将被求值两次。所以，查表的方法被广泛使用。&lt;br /&gt;
&lt;br /&gt;
== 函数 ==&lt;br /&gt;
&lt;br /&gt;
单字节字符处理函数在&amp;lt;code&amp;gt;ctype.h&amp;lt;/code&amp;gt;(C++的&amp;lt;code&amp;gt;cctype&amp;lt;/code&amp;gt; )中声明。宽字节字符处理函数在&amp;lt;code&amp;gt;wctype.h&amp;lt;/code&amp;gt;(C++的&amp;lt;code&amp;gt;cwctype&amp;lt;/code&amp;gt;)中声明.&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size:0.85em;&amp;quot;&lt;br /&gt;
! 单字节&lt;br /&gt;
! 宽字节&lt;br /&gt;
! 描述&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isalnum}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isalnum isalnum]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswalnum}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswalnum iswalnum]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为字母数字&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isalpha}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isalpha isalpha]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswalpha}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswalpha iswalpha]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为字母&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|islower}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/islower islower]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswlower}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswlower iswlower]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为小写字母&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isupper}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isupper isupper]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswupper}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswupper iswupper]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为大写字母&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isdigit}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isdigit isdigit]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswdigit}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswdigit iswdigit]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为数字&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isxdigit}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isxdigit isxdigit]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswxdigit}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswxdigit iswxdigit]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为16进制数字&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|iscntrl}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/iscntrl iscntrl]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswcntrl}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswcntrl iswcntrl]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为控制字符&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isgraph}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isgraph isgraph]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswgraph}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswgraph iswgraph]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为图形字符（例如，空格、控制字符都不是）&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isspace}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isspace isspace]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswspace}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswspace iswspace]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为[[空格字符]]（包括制表符、回车符、换行符等）&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isblank}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isblank isblank]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswblank}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswblank iswblank]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为[[空白字符]] ([[C99]]/[[C++11]]新增)（包括水平制表符）&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|isprint}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/isprint isprint]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswprint}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswprint iswprint]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为可打印字符&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|ispunct}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/ispunct ispunct]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|iswpunct}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswpunct iswpunct]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 是否为标点&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|tolower}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/tolower tolower]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|towlower}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/towlower towlower]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 转换为小写&lt;br /&gt;
|-&lt;br /&gt;
| {{anchor|toupper}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/byte/toupper toupper]&amp;lt;/code&amp;gt;&lt;br /&gt;
| {{anchor|towupper}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/towupper towupper]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 转换为大写&lt;br /&gt;
|-&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{anchor|iswctype}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/iswctype iswctype]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 检查一个&amp;lt;code&amp;gt;wchar_t&amp;lt;/code&amp;gt;是否是属于指定的分类&lt;br /&gt;
|-&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{anchor|towctrans}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/towctrans towctrans]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 使用指定的变换映射来转换一个&amp;lt;code&amp;gt;wchar_t&amp;lt;/code&amp;gt;（实际上是大小写的转换）&lt;br /&gt;
|-&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{anchor|wctype}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/wctype wctype]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 返回一个宽字符的类别，用于&amp;lt;code&amp;gt;iswctype&amp;lt;/code&amp;gt;函数&lt;br /&gt;
|-&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{anchor|wctrans}}&amp;lt;code&amp;gt;[http://en.cppreference.com/w/c/string/wide/wctrans wctrans]&amp;lt;/code&amp;gt;&lt;br /&gt;
| 返回一个变换映射，用于 &amp;lt;code&amp;gt;towctrans&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==参考文献==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
== 外部链接 ==&lt;br /&gt;
{{Wikibooks|A Little C Primer|C Character Class Test Library}}&lt;br /&gt;
{{Wikibooks|C Programming|C character classification|C Programming/C Reference}}&lt;br /&gt;
&lt;br /&gt;
[[Category:C标准库头文件|V]]&lt;/div&gt;</summary>
		<author><name>imported&gt;InternetArchiveBot</name></author>
	</entry>
</feed>