Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
ctype.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _CTYPE_A   0x00000100L /* Alpha */
 
#define _CTYPE_C   0x00000200L /* Control */
 
#define _CTYPE_D   0x00000400L /* Digit */
 
#define _CTYPE_G   0x00000800L /* Graph */
 
#define _CTYPE_L   0x00001000L /* Lower */
 
#define _CTYPE_P   0x00002000L /* Punct */
 
#define _CTYPE_S   0x00004000L /* Space */
 
#define _CTYPE_U   0x00008000L /* Upper */
 
#define _CTYPE_X   0x00010000L /* X digit */
 
#define _CTYPE_B   0x00020000L /* Blank */
 
#define _CTYPE_R   0x00040000L /* Print */
 
#define _CTYPE_I   0x00080000L /* Ideogram */
 
#define _CTYPE_T   0x00100000L /* Special */
 
#define _CTYPE_Q   0x00200000L /* Phonogram */
 
#define _CTYPE_SW0   0x20000000L /* 0 width character */
 
#define _CTYPE_SW1   0x40000000L /* 1 width character */
 
#define _CTYPE_SW2   0x80000000L /* 2 width character */
 
#define _CTYPE_SW3   0xc0000000L /* 3 width character */
 
#define _CTYPE_SWM   0xe0000000L /* Mask for screen width data */
 
#define _CTYPE_SWS   30 /* Bits to shift to get width */
 

Functions

int isalnum (int ch)
 Checks if the given character is an alphanumeric character. More...
 
int isalpha (int ch)
 Checks if the given character is an alphabetic character. More...
 
int isascii (int ch)
 Checks if a given character is a 7-bit US-ASCII character. More...
 
int isblank (int ch)
 Checks if the given character is a blank character. More...
 
int iscntrl (int ch)
 Checks if the given character is a control character. More...
 
int isdigit (int ch)
 Checks if the given character is a numeric character. More...
 
int isgraph (int ch)
 Checks if the given character has a graphical representation. More...
 
int islower (int ch)
 Checks if the given character is classified as a lowercase character. More...
 
int isprint (int ch)
 Checks if the given character can be printed. More...
 
int ispunct (int ch)
 Checks if the given character is a punctuation character. More...
 
int isspace (int ch)
 Checks if the given character is a whitespace character. More...
 
int isupper (int ch)
 Checks if the given character is an uppercase character. More...
 
int isxdigit (int ch)
 Checks if the given character is a hexadecimal numeric character. More...
 
int tolower (int ch)
 Converts the given character to lowercase. More...
 
int toupper (int ch)
 Converts the given character to lowercase. More...
 
int toascii (int ch)
 Converts the given character to ASCII. More...
 

Macro Definition Documentation

◆ _CTYPE_A

#define _CTYPE_A   0x00000100L /* Alpha */

Definition at line 8 of file ctype.h.

◆ _CTYPE_B

#define _CTYPE_B   0x00020000L /* Blank */

Definition at line 17 of file ctype.h.

◆ _CTYPE_C

#define _CTYPE_C   0x00000200L /* Control */

Definition at line 9 of file ctype.h.

◆ _CTYPE_D

#define _CTYPE_D   0x00000400L /* Digit */

Definition at line 10 of file ctype.h.

◆ _CTYPE_G

#define _CTYPE_G   0x00000800L /* Graph */

Definition at line 11 of file ctype.h.

◆ _CTYPE_I

#define _CTYPE_I   0x00080000L /* Ideogram */

Definition at line 19 of file ctype.h.

◆ _CTYPE_L

#define _CTYPE_L   0x00001000L /* Lower */

Definition at line 12 of file ctype.h.

◆ _CTYPE_P

#define _CTYPE_P   0x00002000L /* Punct */

Definition at line 13 of file ctype.h.

◆ _CTYPE_Q

#define _CTYPE_Q   0x00200000L /* Phonogram */

Definition at line 21 of file ctype.h.

◆ _CTYPE_R

#define _CTYPE_R   0x00040000L /* Print */

Definition at line 18 of file ctype.h.

◆ _CTYPE_S

#define _CTYPE_S   0x00004000L /* Space */

Definition at line 14 of file ctype.h.

◆ _CTYPE_SW0

#define _CTYPE_SW0   0x20000000L /* 0 width character */

Definition at line 22 of file ctype.h.

◆ _CTYPE_SW1

#define _CTYPE_SW1   0x40000000L /* 1 width character */

Definition at line 23 of file ctype.h.

◆ _CTYPE_SW2

#define _CTYPE_SW2   0x80000000L /* 2 width character */

Definition at line 24 of file ctype.h.

◆ _CTYPE_SW3

#define _CTYPE_SW3   0xc0000000L /* 3 width character */

Definition at line 25 of file ctype.h.

◆ _CTYPE_SWM

#define _CTYPE_SWM   0xe0000000L /* Mask for screen width data */

Definition at line 26 of file ctype.h.

◆ _CTYPE_SWS

#define _CTYPE_SWS   30 /* Bits to shift to get width */

Definition at line 27 of file ctype.h.

◆ _CTYPE_T

#define _CTYPE_T   0x00100000L /* Special */

Definition at line 20 of file ctype.h.

◆ _CTYPE_U

#define _CTYPE_U   0x00008000L /* Upper */

Definition at line 15 of file ctype.h.

◆ _CTYPE_X

#define _CTYPE_X   0x00010000L /* X digit */

Definition at line 16 of file ctype.h.

Function Documentation

◆ isalnum()

int isalnum ( int  ch)

Checks if the given character is an alphanumeric character.

Checks if the given character is an alphanumeric character using the default locale. The following characters are alphanumeric:

  • digits (0123456789)
  • uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
  • lowercase letters (abcdefghijklmnopqrstuvwxyz)

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is an alphanumeric character, 0 otherwise.

Definition at line 5 of file isalnum.c.

6 {
7  return isalpha(c) || isdigit(c);
8 }
int isalpha(int ch)
Checks if the given character is an alphabetic character.
Definition: isalpha.c:5
int isdigit(int ch)
Checks if the given character is a numeric character.
Definition: isdigit.c:5

References isalpha(), and isdigit().

Referenced by ispunct().

Here is the caller graph for this function:

◆ isalpha()

int isalpha ( int  ch)

Checks if the given character is an alphabetic character.

Checks if the given character is an alphabetic character, i.e. either an uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ), or a lowercase letter (abcdefghijklmnopqrstuvwxyz)

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is an alphabetic character, zero otherwise.

Definition at line 5 of file isalpha.c.

6 {
7  return ((unsigned)c | 32) - 'a' < 26;
8 }

Referenced by isalnum(), strtol(), strtoll(), and strtoul().

Here is the caller graph for this function:

◆ isascii()

int isascii ( int  ch)

Checks if a given character is a 7-bit US-ASCII character.

Checks if a given character 7-bit unsigned char value that fits into the ASCII character set. which is any character between 0 and 0x7f inclusive.

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if ch is a 7-bit US-ASCII character code, zero otherwise.

Definition at line 5 of file isascii.c.

6 {
7  return !(c & ~0x7f);
8 }

◆ isblank()

int isblank ( int  ch)

Checks if the given character is a blank character.

Checks if the given character is a blank character using the default locale. The following characters classified as blank:

  • space (0x20)
  • horizontal tab (0x09)

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is a blank character, zero otherwise.

Definition at line 5 of file isblank.c.

6 {
7  return (c == ' ' || c == '\t');
8 }

Referenced by iswblank().

Here is the caller graph for this function:

◆ iscntrl()

int iscntrl ( int  ch)

Checks if the given character is a control character.

Checks if the given character is a control character. The following are examples of control character:

  • codes (0x00-0x1F) and (0x7F)

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is a control character, zero otherwise.

Definition at line 5 of file iscntrl.c.

6 {
7  return (unsigned)c < 0x20 || c == 0x7f;
8 }

◆ isdigit()

int isdigit ( int  ch)

Checks if the given character is a numeric character.

Checks if the given character is a numeric character (0123456789).

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is a numeric character, zero otherwise.

Definition at line 5 of file isdigit.c.

6 {
7  return (unsigned)c - '0' < 10;
8 }

Referenced by atoi(), atol(), atoll(), isalnum(), isxdigit(), strtol(), strtoll(), and strtoul().

Here is the caller graph for this function:

◆ isgraph()

int isgraph ( int  ch)

Checks if the given character has a graphical representation.

Checks if the given character has a graphical representation using the default locale. The following characters are graphical:

  • number (0123456789)
  • uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
  • letter (abcdefghijklmnopqrstuvwxyz)
  • punctuation character (!"#$%&'()*+,-./:;<=>?@[]^_`{|}~)

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character has a graphical representation character, zero otherwise.

Definition at line 5 of file isgraph.c.

6 {
7  return (unsigned)c - 0x21 < 0x5e;
8 }

Referenced by ispunct().

Here is the caller graph for this function:

◆ islower()

int islower ( int  ch)

Checks if the given character is classified as a lowercase character.

Checks if the given character is classified as a lowercase character using the default local. islower returns true only for the lowercase letters (abcdefghijklmnopqrstuvwxyz). If islower returns true, it is guaranteed that

See also
iscntrl,
isdigit,
ispunct,
isspace will return false for the same character in the same default locale.

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is a lowercase letter, zero otherwise.

Definition at line 5 of file islower.c.

6 {
7  return (unsigned)c - 'a' < 26;
8 }

Referenced by toupper().

Here is the caller graph for this function:

◆ isprint()

int isprint ( int  ch)

Checks if the given character can be printed.

Checks if the given character can be printed using the default locale. The following characters are printable:

  • number (0123456789)
  • uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
  • letter (abcdefghijklmnopqrstuvwxyz)
  • punctuation character (!"#$%&'()*+,-./:;<=>?@[]^_`{|}~)
  • space (0x20)

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character can be printed, zero otherwise.

Definition at line 5 of file isprint.c.

6 {
7  return (unsigned)c - 0x20 < 0x5f;
8 }

◆ ispunct()

int ispunct ( int  ch)

Checks if the given character is a punctuation character.

Checks if the given character is a punctuation character using the default local. The following characters are classified as punctuation character:

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

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is a punctuation character, zero otherwise.

Definition at line 5 of file ispunct.c.

6 {
7  return isgraph(c) && !isalnum(c);
8 }
int isgraph(int ch)
Checks if the given character has a graphical representation.
Definition: isgraph.c:5
int isalnum(int ch)
Checks if the given character is an alphanumeric character.
Definition: isalnum.c:5

References isalnum(), and isgraph().

◆ isspace()

int isspace ( int  ch)

Checks if the given character is a whitespace character.

Checks if the given character is a whitespace character. The following are examples of a whitespace character:

  • space (0x20)
  • feed (0x0c)
  • line feed (0x0a)
  • carriage return (0x0d)
  • horizontal tab (0x09)
  • vertical tab (0x0b)

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is a whitespace character, zero otherwise.

Definition at line 5 of file isspace.c.

6 {
7  return c == ' ' || (unsigned)c - '\t' < 5;
8 }

Referenced by atol(), atoll(), strtol(), strtoll(), strtoul(), and strtoull().

Here is the caller graph for this function:

◆ isupper()

int isupper ( int  ch)

Checks if the given character is an uppercase character.

Checks if the given character is an uppercase character using the default local. isupper returns true only for the uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ). If isupper returns true, it is guaranteed that

See also
iscntrl,
isdigit,
ispunct,
isspace will return false for the same character in the same default locale.

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is an uppercase letter, zero otherwise.

Definition at line 5 of file isupper.c.

6 {
7  return (unsigned)c - 'A' < 26;
8 }

Referenced by strtol(), strtoll(), strtoul(), and tolower().

Here is the caller graph for this function:

◆ isxdigit()

int isxdigit ( int  ch)

Checks if the given character is a hexadecimal numeric character.

Checks if the given character is a hexadecimal numeric character (0123456789).

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chThe character to classify
Returns
Non-zero value if the character is an hexadecimal numeric character, zero otherwise.

Definition at line 5 of file isxdigit.c.

6 {
7  return isdigit(c) || ((unsigned)c | 32) - 'a' < 6;
8 }
int isdigit(int ch)
Checks if the given character is a numeric character.
Definition: isdigit.c:5

References isdigit().

◆ toascii()

int toascii ( int  ch)

Converts the given character to ASCII.

Converts the given character to a 7-bit unsigned char value that fits into the ASCII character set.

Parameters
chcharacter to be converted.
Returns
The value returned is that of the converted letter, or ch if the conversion was not possible.

Definition at line 5 of file toascii.c.

6 {
7  return c & 0x7f;
8 }

◆ tolower()

int tolower ( int  ch)

Converts the given character to lowercase.

Converts the given character to lowercase according to the character conversion rules defined by the default local, i.e. the following uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ) are replaced with respective lowercase letters (abcdefghijklmnopqrstuvwxyz).

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chcharacter to be converted.
Returns
Lowercase version of ch or unmodified ch if no lowercase version is listed in the default locale.

Definition at line 5 of file tolower.c.

6 {
7  if(isupper(c))
8  {
9  {
10  return c | 32;
11  }
12  }
13  return c;
14 }
int isupper(int ch)
Checks if the given character is an uppercase character.
Definition: isupper.c:5

References isupper().

Referenced by towlower().

Here is the caller graph for this function:

◆ toupper()

int toupper ( int  ch)

Converts the given character to lowercase.

Converts the given character to lowercase according to the character conversion rules defined by the default local, i.e. the following lowercase letters (abcdefghijklmnopqrstuvwxyz) are replaced with respective uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ).

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Parameters
chcharacter to be converted.
Returns
Uppercase version of ch or unmodified ch if no uppercase version is listed in the default locale.

Definition at line 5 of file toupper.c.

6 {
7  if(islower(c))
8  {
9  {
10  return c & 0x5f;
11  }
12  }
13  return c;
14 }
int islower(int ch)
Checks if the given character is classified as a lowercase character.
Definition: islower.c:5

References islower().

Referenced by towupper().

Here is the caller graph for this function: