Rookie Engineer

If you aren't the kind of person that feels this way naturally, you'll need to become one in order to make it as a hacker. Otherwise you'll find your hacking energy is sapped by distractions like sex, money, and social approval.

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  24 Posts :: 0 Stories :: 2 Comments :: 0 Trackbacks

常用链接

留言簿

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

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: 成功 != 0 ,失败 = 0
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:
standard white-space characters are:
' ' (0x20) space (SPC)
'\t' (0x09) horizontal tab (TAB)
'\n' (0x0a) newline (LF)
'\v' (0x0b) vertical tab (VT)
'\f' (0x0c) feed (FF)
'\r' (0x0d) carriage return (CR)


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 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) 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.

ps:copy from C++ Reference http://www.cplusplus.com/reference/clibrary/cctype/

posted on 2011-05-31 08:39 micwu 阅读(388) 评论(0)  编辑 收藏 引用 所属分类: C++ Reference

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理