liveBook · Manning

Execution character set

As explained in Modern C, Third Edition

An execution character set is the implementation-defined mapping used to represent characters during C program execution.

The execution character set is the implementation-defined mapping used to represent characters while a C program runs. Numeric character encodings therefore depend on the platform and the particular execution setting. section 8.5

Numeric escapes in strings

Do not assume that "\xdeBruyn" means a character encoded by \xde followed by "Bruyn". The hexadecimal escape consumes every following hexadecimal digit, so it can become one character with code 3,563 followed by "ruyn". Writing "\xde""Bruyn" ends the escape before the next text. Whether code 3,563 exists, and which character it represents, depends on the execution character set. section 8.5

Keep these portability rules in mind:

  • Treat numerically encoded characters as non-portable unless the required character exists with the intended representation. section 8.5
  • Use character classification functions carefully: implementations may extend classes with platform-specific characters. section 8.5
Table 8.14 Character classifiers. The third column indicates whether C implementations may extend these classes with platform-specific characters, such as ’ ä’ as a lowercase character or ’ €’ as punctuation.
Name Meaning C locale Extended
islower Lowercase ’a’ ⋯ ’z’ Yes
isupper Uppercase ’A’ ⋯ ’Z’ Yes
isblank Blank ’ ’, ’'͡ Yes
isspace Space ”, ’'̑, ’’, ’'̊, ’'͡, ’'̌ Yes
isdigit Decimal ’0’ ⋯ ’9’ No
isxdigit Hexadecimal ’0’ ⋯ ’9’, ’a’ ⋯ ’f’, ’A’ ⋯ ’F’ No
iscntrl Control ’’, ’'̱, ’'̑, ’’, ’'̊, ’'͡, ’'̌ Yes
isalnum Alphanumeric isalpha(x)||isdigit(x) Yes
isalpha Alphabet islower(x)||isupper(x) Yes
isgraph Graphical (!iscntrl(x)) && (x != ”) Yes
isprint Printable !iscntrl(x) Yes
ispunct Punctuation isprint(x)&&!(isalnum(x)||isspace(x)) Yes

Compare standard character classes with implementation-defined extensions, including possible additional lowercase or punctuation characters. section 8.5

How Modern C, Third Edition covers it

How deep it goes
Explains hexadecimal escape consumption and platform dependence, but stops short of detailing character-set encodings.
Examples
Uses the strings "\xdeBruyn" and "\xde""Bruyn" to demonstrate hexadecimal escape boundaries.
What you can do after
Evaluate whether numerically encoded characters and escape sequences are portable across execution environments.
How it connects
Connects numeric character escapes with string literals, character classification, locales, and portability.

Also explained in

Compare how 2 books explain execution character set →

Related concepts

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