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
*/
horizontal tab
\ t /* \u0009:
HT */
linefeed
\ n /* \u000a:
LF */
form feed
\ f /* \u000c:
FF */
carriage return
\ r /* \u000d:
CR */
double quote
\ " /* \u0022: " */
single quote
\ ' /* \u0027: ' */
backslash
\ \ /* \u005c: \ */
OctalEscape
/* \u0000
to \u00ff:
from octal value */
OctalEscape:
\
OctalDigit
\
OctalDigitOctalDigit
\
ZeroToThreeOctalDigit
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.)