Character literal
A character literal is the representation of a character value within the source code of a computer program. Languages that have a character data type generally have character literals; these include C, C++, Java, and Visual Basic, but not Python. A common convention is to use a single quote ('
) for character literals and a double quote ("
) for string literals. For example, 'a'
indicates the single character a
while "a"
indicates the string a
of length 1.
Alternative ways to encode literal character values include specifying an integer value for a code point. This may be done directly via converting an integer literal to a character, or via an escape sequence. Character literals are generally syntactically similar to single-character string literals.