Character literal

Description

A character literal consists of one Unicode character or one escape character within single quotes (apostrophes).

Syntax

Table 4.8. Character literal

ProductionSyntaxLinks
character_literal "'" ( Unicode_character | escape_character ) "'"

remark: Unicode_character cannot be "'" or "\" or <carriage_return> or <line_feed>

the section called “Character literal”
Unicode_characterany Unicode_character, like A, B, C, 1, 2, 3, +, -, %, and so on 
escape_character

-> "\b"   /* backspace */
-> "\f"   /* form feed */
-> "\n"   /* line feed */
-> "\r"   /* carriage return */
-> "\t"   /* horizontal tab */
-> '\"'   /* quote (double quote) */
-> "\'"   /* apostrophe (single quote) */
-> "\\"   /* backslash */
-> "\u" hex_digit hex_digit hex_digit hex_digit   /* hexadecimal Unicode character definition */

 

Example 4.13. Character literals

'a'       // a
'7'       // 7
' '       // space
'"'       // double quote
'\''      // single quote
'\t'      // horizontal tab
'\u002f'  // ?