128個ASCII字符(不可打印(控制)或可打印字符)的分類可用以下函數(在類庫<cctype>中)區分:
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 )
128個ASCII字符的編碼并非毫無規律,按十六進制編碼去看,非打印控制字符編排在前面,數字、大寫字母、小寫字母都是一個取整的十六進制數 1開始排在一起。
可打印标點符号(punctuation,上圖紅色字體)被數字、大寫字母、小寫字母分成了四塊。
如果你去考慮字母大小寫的轉換,你會看到其編碼的精心安排之處:
printf("%d\n",'a'-'A'); // 32, 100000b
printf("%c\n",'a'^32); // A, 1000001^100000,相當于加32
printf("%c\n",'A'^32); // a, 1100001^100000,相當于減32
-End-
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!