liveBook · Manning

Character classifier

As explained in Modern C

A character classifier is a C library function or macro that tests whether a character belongs to a specified character class.

A character classifier is a C library function or macro from <ctype.h> that tests whether a character belongs to a class. Classifiers accept and return int, preserving independence from character encoding while allowing platform-specific extensions. section 8.4

Classifying digits before conversion

unsigned hexatridecimal(int a) { if (isdigit(a)) return a - '0'; a = toupper(a); return isupper(a) ? 10 + (a - 'A') : -1; } Here, isdigit identifies decimal digits before arithmetic conversion; toupper normalizes letters, and isupper accepts uppercase alphabetic digits. section 8.4

How Modern C covers it

How deep it goes
Defines the classifier families and demonstrates their use, but defers broader library-interface details.
Examples
Uses a classifier table and a hexatridecimal conversion function to demonstrate classification before arithmetic.
What it assumes
Assumes basic C character constants and introduces character classes through library interfaces.
What you can do after
Apply <ctype.h> predicates to classify characters during portable parsing and conversion.
How it connects
Connects character classifiers with character encoding, locale, case conversion, and string conversion.

Also explained in

Compare how 2 books explain character classifier →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.