XINU
Macros | Variables
ctype.h File Reference

「文字種類の判定」や「文字変換」を行う関数マクロを提供する。 More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _C   0x20
 制御文字 (control character)を判定するためのビットマスク More...
 
#define _L   0x02
 アルファベット小文字を判定するためのビットマスク More...
 
#define _N   0x04
 10進数の文字を判定するためのビットマスク More...
 
#define _P   0x10
 区切り文字を判定するためのビットマスク More...
 
#define _S   0x08
 空白文字を判定するためのビットマスク More...
 
#define _U   0x01
 アルファベット大文字を判定するためのビットマスク More...
 
#define _X   0x40
 16進数の文字を判定するためのビットマスク More...
 
#define isalnum(c)   ((_ctype_ + 1)[(int)c] & (_U | _L | _N))
 文字がアルファベットもしくは数字かどうかをチェックするマクロ More...
 
#define isalpha(c)   ((_ctype_ + 1)[(int)c] & (_U | _L))
 文字がアルファベットかどうかをチェックするマクロ More...
 
#define isascii(c)   ((unsigned)((int)(c)) <= 0x7F)
 文字がASCII文字かどうかをチェックするマクロ More...
 
#define iscntrl(c)   ((_ctype_ + 1)[(int)c] & _C)
 文字が制御文字 (control character) かどうかをチェックするマクロ More...
 
#define isdigit(c)   ((_ctype_ + 1)[(int)c] & _N)
 文字が10進数の数字かどうかをチェックするマクロ More...
 
#define iseof(c)   (0x04 == (int)c)
 文字がEnd Of File(制御文字)かどうかをチェックするマクロ More...
 
#define islower(c)   ((_ctype_ + 1)[(int)c] & _L)
 文字がアルファベットの小文字かどうかをチェックするマクロ More...
 
#define isprint(c)   ((_ctype_ + 1)[(int)c] & (_P | _U | _L | _N | _S))
 文字が表示文字かどうかをチェックするマクロ More...
 
#define ispunct(c)   ((_ctype_ + 1)[(int)c] & _P)
 文字が区切り文字 (punctuation character) かどうかをチェックするマクロ More...
 
#define isspace(c)   ((_ctype_ + 1)[(int)c] & _S)
 文字が空白かどうかをチェックするマクロ More...
 
#define isupper(c)   ((_ctype_ + 1)[(int)c] & _U)
 文字がアルファベットの大文字かどうかをチェックするマクロ More...
 
#define isxdigit(c)   ((_ctype_ + 1)[(int)c] & (_N | _X))
 文字が16進数の数字かどうかをチェックするマクロ More...
 
#define toascii(c)   (((int)(c)) & 0x7F)
 
#define tolower(c)   (((int)(c)) - 'A' + 'a')
 アルファベットの大文字を小文字に変換するマクロ More...
 
#define toupper(c)   (((int)(c)) - 'a' + 'A')
 アルファベットの小文字を大文字に変換するマクロ More...
 

Variables

const char _ctype_ []
 「文字種類の判定」や「文字変換」の際に使用するビットマスク配列 More...
 

Detailed Description

「文字種類の判定」や「文字変換」を行う関数マクロを提供する。

ASCII文字コード表
[16進数] [10進数]
2 3 4 5 6 7 30 40 50 60 70 80 90 100 110 120
----------— ------------------------------—
0: 0 @ P ` p 0: ( 2 < F P Z d n x
1: ! 1 A Q a q 1: ) 3 = G Q [ e o y
2: " 2 B R b r 2: * 4 > H R \ f p z
3: # 3 C S c s 3: ! + 5 ? I S ] g q {
4: $ 4 D T d t 4: " , 6 @ J T ^ h r |
5: % 5 E U e u 5: # - 7 A K U _ i s }
6: & 6 F V f v 6: $ . 8 B L V ` j t ~
7: ' 7 G W g w 7: % / 9 C M W a k u DEL
8: ( 8 H X h x 8: & 0 : D N X b l v
9: ) 9 I Y i y 9: ' 1 ; E O Y c m w
A: * : J Z j z
B: + ; K [ k {
C: , < L \ l |
D: - = M ] m }
E: . > N ^ n ~
F: / ? O _ o DEL
※ 16進数は列の値に、行の値を連結して読む(列=7、行=Aの場合、7A='z')
※ 10進数は列の値に、行の値を加算して読む(列=50、行=6の場合、56='8')

Note
Doxygenドキュメント上ではASCII表がズレるため、ASCII表のスクショを併記する。
ascii.png

Definition in file ctype.h.

Macro Definition Documentation

◆ _C

#define _C   0x20

制御文字 (control character)を判定するためのビットマスク

Definition at line 41 of file ctype.h.

◆ _L

#define _L   0x02

アルファベット小文字を判定するためのビットマスク

Definition at line 33 of file ctype.h.

◆ _N

#define _N   0x04

10進数の文字を判定するためのビットマスク

Definition at line 35 of file ctype.h.

◆ _P

#define _P   0x10

区切り文字を判定するためのビットマスク

Definition at line 39 of file ctype.h.

◆ _S

#define _S   0x08

空白文字を判定するためのビットマスク

Definition at line 37 of file ctype.h.

◆ _U

#define _U   0x01

アルファベット大文字を判定するためのビットマスク

Definition at line 31 of file ctype.h.

◆ _X

#define _X   0x40

16進数の文字を判定するためのビットマスク

Definition at line 43 of file ctype.h.

◆ isalnum

#define isalnum (   c)    ((_ctype_ + 1)[(int)c] & (_U | _L | _N))

文字がアルファベットもしくは数字かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字がアルファベットもしくは数字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 110 of file ctype.h.

◆ isalpha

#define isalpha (   c)    ((_ctype_ + 1)[(int)c] & (_U | _L))

文字がアルファベットかどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字がアルファベットの場合はtrue、それ以外の場合はfalseを返す。

Definition at line 54 of file ctype.h.

◆ isascii

#define isascii (   c)    ((unsigned)((int)(c)) <= 0x7F)

文字がASCII文字かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字がASCII文字の場合はtrue、それ以外の場合はfalseを返す。
Note
ASCII文字は、0x7F=127が終端となる。

Definition at line 135 of file ctype.h.

◆ iscntrl

#define iscntrl (   c)    ((_ctype_ + 1)[(int)c] & _C)

文字が制御文字 (control character) かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字が制御文字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 126 of file ctype.h.

◆ isdigit

#define isdigit (   c)    ((_ctype_ + 1)[(int)c] & _N)

文字が10進数の数字かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字が10進数の数字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 78 of file ctype.h.

Referenced by _doscan(), _innum(), and config_atoi().

◆ iseof

#define iseof (   c)    (0x04 == (int)c)

文字がEnd Of File(制御文字)かどうかをチェックするマクロ

Parameters
[in]c任意の文字
Returns
文字がEnd Of File(制御文字)の場合はtrue、それ以外はfalseを返す。

Definition at line 169 of file ctype.h.

◆ islower

#define islower (   c)    ((_ctype_ + 1)[(int)c] & _L)

文字がアルファベットの小文字かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字がアルファベットの小文字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 70 of file ctype.h.

◆ isprint

#define isprint (   c)    ((_ctype_ + 1)[(int)c] & (_P | _U | _L | _N | _S))

文字が表示文字かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字が表示文字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 118 of file ctype.h.

◆ ispunct

#define ispunct (   c)    ((_ctype_ + 1)[(int)c] & _P)

文字が区切り文字 (punctuation character) かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字が区切り文字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 102 of file ctype.h.

◆ isspace

#define isspace (   c)    ((_ctype_ + 1)[(int)c] & _S)

文字が空白かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字が空白の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 94 of file ctype.h.

◆ isupper

#define isupper (   c)    ((_ctype_ + 1)[(int)c] & _U)

文字がアルファベットの大文字かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字がアルファベットの大文字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 62 of file ctype.h.

Referenced by _doscan(), and config_atoi().

◆ isxdigit

#define isxdigit (   c)    ((_ctype_ + 1)[(int)c] & (_N | _X))

文字が16進数の数字かどうかをチェックするマクロ

Parameters
[in]cチェック対象の文字
Returns
文字が16進数の数字の場合はtrue、それ以外の場合はfalseを返す。

Definition at line 86 of file ctype.h.

◆ toascii

#define toascii (   c)    (((int)(c)) & 0x7F)

Definition at line 161 of file ctype.h.

◆ tolower

#define tolower (   c)    (((int)(c)) - 'A' + 'a')

アルファベットの大文字を小文字に変換するマクロ

文字をASCII文字に変換するマクロ

Parameters
[in]cアルファベットの大文字
Returns
アルファベットの小文字
Parameters
[in]c任意の文字
Returns
ASCIIに変換された文字
Note
最上位ビットをクリアし、ASCII文字コードに適合するように文字cを
7bitの unsigned char に変換する。0x7F=0b0111_1111。

Referenced by _doscan().

◆ toupper

#define toupper (   c)    (((int)(c)) - 'a' + 'A')

アルファベットの小文字を大文字に変換するマクロ

Parameters
[in]cアルファベットの小文字
Returns
アルファベットの大文字

Definition at line 143 of file ctype.h.

Variable Documentation

◆ _ctype_

const char _ctype_[]

「文字種類の判定」や「文字変換」の際に使用するビットマスク配列

「文字種類の判定」や「文字変換」の際に使用するビットマスク配列

Note
ASCII文字は7bit(0〜127の数値)で表される。そのため、_ctype_配列に
英字、数値、制御文字などを判定するためのビットマスクを予め仕込んでおき、
Step1. チェック対象文字を配列の添字として、_ctype_配列からビットマスクを取得
Step2. 前手順Step2.で取得したビットマスクが期待値通りかチェック
という手順を実施する事によって、文字の種類を判定できる。

Definition at line 39 of file ctype_.c.