C标准库源码解读(VC9.0版本)——ctype.h

      ANSI C文档(C89 http://flash-gordon.me.uk/ansi.c.txt)如是说:

4.3 CHARACTER HANDLING <ctype.h>  

The header <ctype.h> declares several functions useful for testingand mapping characters./89/ In all cases the argument is an int , the value of which shall be representable as an unsigned char or shallequal the value of the macro EOF .  If the argument has any othervalue, the behavior is undefined.

      这里说明了ctype.h里面实现的所有测试字符的函数传进去的参数都以int形参给出,并且有效值是无符号字符(unsigned char)或EOF宏(通常实现为-1),其他输入的int型值行为未定义。

      C标准库规定了需要实现的13个字符处理函数,可以分为两类——字符测试函数和字符转换函数。

      下面给出了C99的字符测试函数表,表中是12个字符测试函数,比原来的标准多出来一个isblank。http://www.open-std.org/JTC1/SC22/WG14/www/docs/C99RationaleV5.10.pdf P118

7.4.1.3 The isblank function

A new feature of C99: text processing applications often need to distinguish white space that can 15 occur within lines from white space that separates lines (for example, see §6.10 regarding use of whitespace in the preprocessor). This distinction is also a property of POSIX locale definition files.

 

ASCII values characters iscntrl isblank isspace isupper islower isalpha isdigit isxdigit isalnum ispunct isgraph isprint
0x00 .. 0x08 NUL, (other control codes) x                      
0x09 tab ('\t') x x x                  
0x0A .. 0x0D (white-space control codes: '\f','\v','\n','\r') x   x                  
0x0E .. 0x1F (other control codes) x                      
0x20 space (' ')   x x                 x
0x21 .. 0x2F !"#$%&'()*+,-./                   x x x
0x30 .. 0x39 0123456789             x x x   x x
0x3a .. 0x40 :;<=>?@                   x x x
0x41 .. 0x46 ABCDEF       x   x   x x   x x
0x47 .. 0x5A GHIJKLMNOPQRSTUVWXYZ       x   x     x   x x
0x5B .. 0x60 [\]^_`                   x x x
0x61 .. 0x66 abcdef         x x   x x   x x
0x67 .. 0x7A ghijklmnopqrstuvwxyz         x x     x   x x
0x7B .. 0x7E {|}~                   x x x
0x7F (DEL) x                      

上表来源:http://www.cplusplus.com/reference/cctype/

下面英文部分是字符测试函数要求描述,摘自C89标准文档说明

4.3.1 Character testing functions  

The functions in this section return nonzero (true) if and only ifthe value of the argument c conforms to that in the description of thefunction.

4.3.1.1 The isalnum functionSynopsis        

 #include <ctype.h>        

int isalnum(int c);

Description   The isalnum function tests for any character for which isalpha orisdigit is true.

 

4.3.1.2 The isalpha functionSynopsis        

#include <ctype.h>        

 int isalpha(int c);

Description   The isalpha function tests for any character for which isupper orislower is true, or any of an implementation-defined set of charactersfor which none of iscntrl , isdigit , ispunct , or isspace is true.In the C locale, isalpha returns true only for the characters forwhich isupper or islower is true.

 

4.3.1.3 The iscntrl functionSynopsis        

 #include <ctype.h>        

int iscntrl(int c);

Description   The iscntrl function tests for any control character. 

 

4.3.1.4 The isdigit functionSynopsis        

 #include <ctype.h>        

int isdigit(int c);

Description   The isdigit function tests for any decimal-digit character (asdefined in $2.2.1).

 

4.3.1.5 The isgraph functionSynopsis        

 #include <ctype.h>        

int isgraph(int c);

Description   The isgraph function tests for any printing character except space (' '). 

 

4.3.1.6 The islower functionSynopsis        

#include <ctype.h>        

int islower(int c);Description  

The islower function tests for any lower-case letter or any of animplementation-defined set of characters for which none of iscntrl ,isdigit , ispunct , or isspace is true.  In the C locale, islowerreturns true only for the characters defined as lower-case

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值