Class Reference ctype.h

Character tests and case conversion for C++ macros. More...

Member

int isalnum(int c)
int isalpha(int c)
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)
int tolower(int c)
int toupper(int c)

Detailed Description

Character tests and case conversion for C++ macros. Load with #include <ctype.h> or #include <cctype> (same plugin). Available from LayoutEditor 20260918.

These functions do not take a LayoutEditor string. They take a character code: a whole number that stands for one character in the usual 7-bit ASCII table.

In a macro, 'A' is a string, not a character. Do not write isalpha('A'). Pass the code instead:

Character Code
'0''9' 48 … 57
'A''Z' 65 … 90
'a''z' 97 … 122
space 32
newline 10

You can also take the first byte of a string if you already have one character in a variable of type int.

The is… functions return non-zero when the test is true, and 0 when it is false. In an if that is enough: if (isdigit(48)) { … }.

Locale-dependent (national) character sets are not bound.

Example

#include <ctype.h>

int main(){
    if (!isdigit(48)) return 1;          // '0'
    if (!isalpha(65)) return 1;          // 'A'
    int up = toupper(97);                 // 'a' → 65 ('A')
    cout("toupper('a') = ", up, "\n");
}

Member Function Documentation


int ctype.h::isalnum(int c)

True if c is a letter or a digit (AZ, az, 09).

Parameters:

  • c (int) — character code.

Returns: non-zero if alphanumeric, otherwise 0.


int ctype.h::isalpha(int c)

True if c is a letter (AZ or az).

Parameters:

  • c (int) — character code.

Returns: non-zero if a letter, otherwise 0.


int ctype.h::iscntrl(int c)

True if c is a control character (codes 0–31 and 127: tab, newline, bell, … — not a visible glyph).

Parameters:

  • c (int) — character code.

Returns: non-zero if a control character, otherwise 0.


int ctype.h::isdigit(int c)

True if c is a decimal digit 09 (codes 48–57).

Parameters:

  • c (int) — character code.

Returns: non-zero if a digit, otherwise 0.


int ctype.h::isgraph(int c)

True if c is a visible character except space (letters, digits, punctuation).

Parameters:

  • c (int) — character code.

Returns: non-zero if visible and not space, otherwise 0.


int ctype.h::islower(int c)

True if c is a lowercase letter az.

Parameters:

  • c (int) — character code.

Returns: non-zero if lowercase, otherwise 0.


int ctype.h::isprint(int c)

True if c is printable, including space (code 32 and visible glyphs).

Parameters:

  • c (int) — character code.

Returns: non-zero if printable, otherwise 0.


int ctype.h::ispunct(int c)

True if c is punctuation (printable, but neither letter, digit, nor space): ., ,, !, (, …

Parameters:

  • c (int) — character code.

Returns: non-zero if punctuation, otherwise 0.


int ctype.h::isspace(int c)

True if c is white space: space, tab (9), newline (10), vertical tab (11), form feed (12), carriage return (13).

Parameters:

  • c (int) — character code.

Returns: non-zero if white space, otherwise 0.


int ctype.h::isupper(int c)

True if c is an uppercase letter AZ.

Parameters:

  • c (int) — character code.

Returns: non-zero if uppercase, otherwise 0.


int ctype.h::isxdigit(int c)

True if c is a hexadecimal digit: 09, AF, af.

Parameters:

  • c (int) — character code.

Returns: non-zero if a hex digit, otherwise 0.


int ctype.h::tolower(int c)

Converts an uppercase letter to lowercase. Other codes are returned unchanged.

Parameters:

  • c (int) — character code (65 for 'A').

Returns: int — the converted code. tolower(65) is 97 ('a'). tolower(48) is 48 ('0' stays a digit).


int ctype.h::toupper(int c)

Converts a lowercase letter to uppercase. Other codes are returned unchanged.

Parameters:

  • c (int) — character code (97 for 'a').

Returns: int — the converted code. toupper(97) is 65 ('A').

Python: c.isdigit(), c.isalpha(), c.upper(). This include is for C++ macros only.