Character literal

From Wikipedia, the free encyclopedia

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.

See also


This article is issued from Wikipedia. The text is available under the Creative Commons Attribution/Share Alike; additional terms may apply for the media files.