字符函数库 cctype
<cctype> (ctype.h)
Character handling functions
This header declares a set of functions to classify and transform individual characters.
Functions
These functions take the int equivalent of one character as parameter 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 0represents true.
There are two sets of functions:
Character classification functions
They check whether the character passed as parameter belongs to a certain category:
- isalnum
- Check if character is alphanumeric (function )
- isalpha
- Check if character is alphabetic (function )
- isblank
- Check if character is blank (function )
- iscntrl
- Check if character is a control character (function )
- isdigit
- Check if character is decimal digit (function )
- isgraph
- Check if character has graphical representation (function )
- islower
- Check if character is lowercase letter (function )
- isprint
- Check if character is printable (function )
- ispunct
- Check if character is a punctuation character (function )
- isspace
- Check if character is a white-space (function )
- isupper
- Check if character is uppercase letter (function )
- isxdigit
- Check if character is hexadecimal digit (function )
Character conversion functions
Two functions that convert between letter cases:
- tolower
- Convert uppercase letter to lowercase (function )
- toupper
- Convert lowercase letter to uppercase (function )
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 | 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 |
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.
字符函数库 cctype的更多相关文章
- 学习笔记二十三——字符函数库cctype【转】
本文转载自: 字符函数库cctype 在头文件cctype(ctype.h)中定义了一些函数原型,可以简化输入确定字符是否为大写字母.数字.标点符号等工作. 例如: 如果ch是一个字母,则isalph ...
- 循环 与 分支语句 和 字符函数库cctype 文件简单处理
循环 for循环 while循环 do while循环 通常,入口条件循环比出口条件循环好,因为循环开始前对条件进行检查 c++11基于范围的for循环 对数组(或容器类,如:vector和a ...
- C++学习笔记之字符函数库cctype
C++从C语言继承了一个与字符相关的.非常方便的函数软件包,它可以简化诸如确定字符是否为大写字母.数字.标点符号等工作,这些函数原型是在头文件cctype(老式风格ctype.h)中定义的. 下表对这 ...
- 字符函数库 - cctype 和 climits 中的符号常量
一. C++从C语言中继承一个与字符相关的.非常方便的函数软件包,他可以简化诸如确定字符是否为大写字母‘数字.标点符号等工作,这些函数的原型在头文件cctype(老式的为ctype.h)中定义的.例如 ...
- python函数库及函数标准库
一.系统库提供的内部函数 字符函数库: 1)str.islower() :字符串是否全部是小写 2)str.isspace() :字符串是否为空 3)help(str):查询字符串函数库 4)str. ...
- PHP移动互联网开发笔记(5)——基础函数库
一.数学函数库 ● floor 舍一取整(向下取整) float floor (float $value); <?php echo(floor(0.60)."<br>&qu ...
- cctype头文件(字符处理库)的使用
C++ 中cctype头文件的使用 头文件cctype(字符处理库)中定义了有关字符判断与处理的库函数,使用前要包含头文件: #include <cctype> using namespa ...
- PHP用mb_string函数库处理与windows相关中文字符
昨天想批处理以前下载的一堆文件,把文件里的关键内容用正则匹配出来,集中处理.在操作文件时遇到一个问题,就是windows操作系统中的编码问题. 我们都知道windows中(当然是中文版),文件名和文件 ...
- 【C++实现python字符串函数库】二:字符串匹配函数startswith与endswith
[C++实现python字符串函数库]字符串匹配函数startswith与endswith 这两个函数用于匹配字符串的开头或末尾,判断是否包含另一个字符串,它们返回bool值.startswith() ...
随机推荐
- jQuery第四章
jQuery中的事件和动画 一.jQuery中的事件 1.加载DOM (1)执行时机 $(document).ready()方法和window.onload方法有相似的功能,但是在执行时机方面是有区别 ...
- php日期转时间戳,指定日期转换成时间戳
写过PHP+MySQL的程序员都知道有时间差,UNIX时间戳和格式化日期是我们常打交道的两个时间表示形式,Unix时间戳存储.处理方便,但 是不直观,格式化日期直观,但是处理起来不如Unix时间戳那么 ...
- 【解题报告】Math
= =本来昨天就该发的,只是断网……. MATH [题目描述] 小 x正在做他的数学作业,可是作业实在太难了.题目是这样的: 1.给定一个含有N个数的数列 V. 2.你可以从数列中恰好移除 K个数, ...
- 关于Android L软件安装问题的发现
android5.0可能存在的问题: 保留数据刷入导致通知栏无法下拉 按home键不能回到桌面 sdcard无法读取等等 刷了Android L之后,有一部分软件无法正常安装,多表现为 同一家公司开发 ...
- (转)了解JNDI
JNDI是 Java 命名与目录接口(Java Naming and Directory Interface),在J2EE规范中是重要的规范之一,不少专家认为,没有透彻理解JNDI的意义和作用,就没有 ...
- [SOJ] 1282. Computer games (KMP)
坑爹题 1282. Computer Game Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description Brian is an ...
- 模拟器SDK路径
I'm guessing you already find it out, but just for the record: the UIKit.framework is available only ...
- PHP中使用CURL(六)
curl常用的几个例子 1.抓取无访问控制文件 <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://local ...
- C# 语言规范_版本5.0 (第0章 目录)
C# 语言规范 版本5.0 注意 © 1999-2012 Microsoft Corporation.保留所有权利. Microsoft.Windows.Visual Basic.Visual C# ...
- Excel教程(6) - 外部函数
EUROCONVERT 用途:将数字转换为欧元形式,将数字由欧元形式转换为 欧盟成员国货币形式,或利用欧元作为中间货币将数字由某一 欧盟成员国货币转化为另一欧盟成员国货币的形式(三角转换 关系). 语 ...