15.3.19 Modula-2 Format Strings

Modula-2 format strings are defined as follows:

  1. Escape sequences are processed. These escape sequences are understood: ‘\a’, ‘\b’, ‘\e’, ‘\f’, ‘\n’, ‘\r’, ‘\xhex-digits’, ‘\octal-digits’. Other than that, a backslash is ignored.
  2. A directive consists of
    • a ‘%’ character,
    • optionally a flag character ‘-’,
    • optionally a flag character ‘0’,
    • optionally a width specification (a nonnegative integer),
    • and finally a specifier: ‘s’ that formats a string, ‘c’ that formats a character, ‘d’ and ‘u’, that format a (signed/unsigned) integer in decimal, or ‘x’, that formats an unsigned integer in hexadecimal.

    There is also the directive ‘%%’, that produces a single percent character.