c_c++ :字符处理

来源:互联网 发布:金域名人大酒店 编辑:程序博客网 时间:2024/06/07 00:39

头文件: cctype    (ctype.h)

说明: 字符处理库
功能一:字符测试
1> 函数原型均为int isxxxx(int)
2> 参数为int, 任何实参均被提升成整型
3> 只能正确处理处于[0, 127]之间的值
 

功能二:字符映射
1> 函数原型为int toxxxx(int)
2> 对参数进行检测, 若符合范围则转换, 否则不变

For the first set, here is a map of how theoriginal 127-character ASCII set is considered by each function (an x indicatesthat the function returns true on that character)

ASCII values

characters

iscntrl

isspace

isupper

islower

isalpha

isdigit

isxdigit

isalnum

ispunct

isgraph

isprint

0x00 .. 0x08

NUL, (other control codes)

x

 

 

 

 

 

 

 

 

 

 

0x09 .. 0x0D

(white-space control codes: '\t','\f','\v','\n','\r')

x

x

 

 

 

 

 

 

 

 

 

0x0E .. 0x1F

(other control codes)

x

 

 

 

 

 

 

 

 

 

 

0x20

space (' ')

 

x

 

 

 

 

 

 

 

 

x

0x21 .. 0x2F

!"#$%&'()*+,-./

 

 

 

 

 

 

 

 

x

x

x

0x30 .. 0x39

01234567890

 

 

 

 

 

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)