3.10.6 Escape Sequences for Character and String Literals

The character and string escape sequences allow for the representation of some nongraphic characters as well as the single quote, double quote, and backslash characters in character literals (§3.10.4) and string literals (§3.10.5).

EscapeSequence:
\ b /* \u0008: backspace BS */
\ t /* \u0009:
horizontal tab HT */
\ n /* \u000a:
linefeed LF */
\ f /* \u000c:
form feed FF */
\ r /* \u000d:
carriage return CR */
\ " /* \u0022:
double quote " */
\ ' /* \u0027:
single quote ' */
\ \ /* \u005c:
backslash \ */
OctalEscape /* \u0000 to \u00ff: from octal value */

OctalEscape:
\ OctalDigit
\ OctalDigit OctalDigit
\ ZeroToThree OctalDigit OctalDigit
OctalDigit: one of
0 1 2 3 4 5 6 7
ZeroToThree: one of
0 1 2 3

It is a compile-time error if the character following a backslash in an escape is not an ASCII b, t, n, f, r, ", ', \, 0, 1, 2, 3, 4, 5, 6, or 7. The Unicode escape \u is processed earlier (§3.3). (Octal escapes are provided for compatibility with C, but can express only Unicode values \u0000 through \u00FF, so Unicode escapes are usually preferred.)