C 標準庫 - ctype.h

C 標準庫 - ctype.h

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

  • 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 0 represents true.
  • C 標準庫的 ctype.h 頭文件提供了一些函數,可用於測試和映射字符。

這些函數接受 int 做爲參數,它的值必須是 EOF 或表示爲一個無符號字符。
若是參數 c 知足描述的條件,則這些函數返回非零(true)。若是參數 c 不知足描述的條件,則這些函數返回零。git

函數

//Character classification functions
//They check whether the character passed as parameter belongs to a certain category:
int isalnum(int c)
檢查所傳的字符是不是字母和數字。

int isalpha(int c)
檢查所傳的字符是不是字母。

int isblank (int c)
Check if character is blank

int iscntrl(int c)
檢查所傳的字符是不是控制字符。

int isdigit(int c)
檢查所傳的字符是不是十進制數字。

int isgraph(int c)
檢查所傳的字符是否有圖形表示法。

int islower(int c)
檢查所傳的字符是不是小寫字母。

int isprint(int c)
檢查所傳的字符是不是可打印的。

int ispunct(int c)
檢查所傳的字符是不是標點符號字符。

int isspace(int c)
檢查所傳的字符是不是空白字符。

int isupper(int c)
檢查所傳的字符是不是大寫字母。

int isxdigit(int c)
檢查所傳的字符是不是十六進制數字。


//Character conversion functions
int tolower(int c)
把大寫字母轉換爲小寫字母。

int toupper(int c)
把小寫字母轉換爲大寫字母。

字符類

數字 (Digits)

  • A set of whole numbers { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
  • 完整的數字集合 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }

十六進制數字 (Hexadecimal digits)

  • This is the set of { 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f }
  • 集合 { 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f }

小寫字母 (Lowercase letters)

  • This is a set of { a b c d e f g h i j k l m n o p q r s t u v w x y z }
  • 集合 { a b c d e f g h i j k l m n o p q r s t u v w x y z }

大寫字母 (Uppercase letters)

  • A set of whole numbers {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }
  • 集合 {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }

字母 (Letters)

  • This is a set of lowercase letters and uppercase letters
  • 小寫字母和大寫字母的集合

字母數字字符 (Alphanumeric characters)

  • This is a set of Digits, Lowercase letters and Uppercase letters
  • 數字、小寫字母和大寫字母的集合

標點符號字符 (Punctuation characters)

  • This is a set of ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ ] ^ _ ` { | } ~
  • 集合 ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ ] ^ _ ` { | } ~

圖形字符 (Graphical characters)

  • This is a set of Alphanumeric characters and Punctuation characters.
  • 字母數字字符和標點符號字符的集合

空格字符 (Space characters)

  • This is a set of Alphanumeric characters and Punctuation characters.
  • 製表符、換行符、垂直製表符、換頁符、回車符、空格符的集合。

可打印字符

  • This is a set of Alphanumeric characters, Punctuation characters and Space characters.
  • 字母數字字符、標點符號字符和空格字符的集合。

控制字符 (Control characters)

  • In ASCII, these characters have octal codes 000 through 037, and 177 (DEL).
  • 在 ASCII 編碼中,這些字符的八進制代碼是從 000 到 037,以及 177(DEL)。

空白字符 (Blank characters)

  • These are space and tab.
  • 包括空格符和製表符。

字母字符 (Alphabetic characters)

  • This is a set of Lowercase letters and Uppercase letters.
  • 小寫字母和大寫字母的集合。

ASCII

0 -  8           0x00-0x08    控制碼 (NUL等)           
 9 -  9        0x09            製表符 (\t)             
10 - 13           0x0A-0x0D    空白符 (\n, \v, \f, \r) 
14 - 31           0x0E-0x1F    控制碼                   
32 - 32        0x20            空格                    
33 - 47           0x21-0x2F    !"#$%&'()*+,-./           
48 - 57           0x30-0x39    0123456789               
58 - 64           0x3a-0x40    :;<=>?@                    
65 - 70           0x41-0x46    ABCDEF                   
71 - 90           0x47-0x5A    GHIJKLMNOPQRSTUVWXYZ    
91 - 96           0x5B-0x60    [\]^_`                   
97 -102           0x61-0x66    abcdef                    
103-122           0x67-0x7A    ghijklmnopqrstuvwxyz    
123-126           0x7B-0x7E    {|}~                 
127               0x7F            退格符 (DEL)

參考文章

相關文章
相關標籤/搜索