C++ 字符函数库cctype

cctype (ctype.h)

<C++ Primer 第四版> 3.2.4 节 string 对象中字符的处理

<C++ Primer Plus 第五版> 6.3 节 字符函数库 cctype(比前者多个isblank介绍, 比较详细)


header

Character handling functions

This header declares a set of functions to classify and transform individual characters.

All these functions take as parameter the int equivalent of one character and return an int, that can either be another character or a value representing a boolean value: an int value of 0 means false, and an int value different from 0 represents true.

There are two sets of functions:

First a set of classifying functions that check whether the character passed as parameter belongs to a certain category. These are:


(C++ Primer Plus 第五版)


And secondly, two functions to convert between letter cases:


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

ASCII valuescharactersiscntrlisspaceisupperislowerisalphaisdigitisxdigitisalnumispunctisgraphisprint
0x00 .. 0x08

NUL, (other control

codes)

x          
0x09 .. 0x0D

(white-space control

codes:

'/t','/f','/v','/n','/r')

xx         
0x0E .. 0x1F(other control codes)x          
0x20space (' ') x        x
0x21 .. 0x2F!"#$%&'()*+,-./        xxx
0x30 .. 0x3901234567890     xxx xx
0x3a .. 0x40:;<=>?@        xxx
0x41 .. 0x46ABCDEF  x x xx xx
0x47 .. 0x5AGHIJKLMNOPQRSTUVWXYZ  x x  x xx
0x5B .. 0x60[/]^_`        xxx
0x61 .. 0x66abcdef   xx xx xx
0x67 .. 0x7Aghijklmnopqrstuvwxyz   xx  x xx
0x7B .. 0x7E{|}~        xxx
0x7F(DEL)x          


The characters in the extended character set (above 0x7F) may belong to diverse categories depending on the locale and the platform. As a general rule, ispunct, isgraph and isprint return true on these for the standard C locale on most platforms supporting extended character sets.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值