ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:ctype

Character functions

ACSUtils implements functions from the C programming language's ctype.h. Only ASCII characters are supported.

Character classification

  • bool isalnum(int c) – returns true if the character is a letter or a digit.
  • bool isalpha(int c) – returns true if the character is a letter.
  • bool isblank(int c) – returns true if the character is blank.
  • bool iscntrl(int c) – returns true if the character is a control character.
  • bool isdigit(int c) – returns true if the character is a digit.
  • bool isgraph(int c) – returns true if the character has a graphical representation.
  • bool islower(int c) – returns true if the character is lowercase.
  • bool isprint(int c) – returns true if the character is printable. Inverse of iscntrl().
  • bool isprint(int c) – returns true if the character is a punctuation character.
  • bool isspace(int c) – returns true if the character whitespace.
  • bool isupper(int c) – returns true if the character is uppercase.
  • bool isxdigit(int c) – returns true if the character is a hexadecimal digit (0123456789abcdef).

ACSUtils additions:

  • bool isascii(int c) – returns true if the character is an ASCII character.

Character classification functions return false for all non-ASCII characters.

Case conversion

If the character is not a letter, these functions return the original character:

  • int tolower(int c) – returns the lowercase version of the character.
  • int toupper(int c) – returns the uppercase version of the character.

Non-ASCII characters are always returned without conversion.

String versions of the above functions

These functions return true if all characters in the string match a character classification function:

  • bool StrIsAscii(str s)isascii
  • bool StrIsAlnum(str s)isalnum
  • bool StrIsAlpha(str s)isalpha
  • bool StrIsBlank(str s)isblank
  • bool StrIsCntrl(str s)iscntrl
  • bool StrIsDigit(str s)isdigit
  • bool StrIsGraph(str s)isgraph
  • bool StrIsLower(str s)islower
  • bool StrIsPrint(str s)isprint
  • bool StrIsSpace(str s)isspace
  • bool StrIsUpper(str s)isupper
  • bool StrIsXDigit(str s)isxdigit

These functions make all characters in the string lowercase or uppercase:

  • str StrToLower(str s) – returns the string with all characters converted to lowercase.
  • str StrToUpper(str s) – returns the string with all characters converted to uppercase.
new/ctype.txt · Last modified: 2018/02/20 19:41 by korshun