The character data type can be specified as follows:
If no kind type parameter is specified, the kind of the constant is default character.
A character constant is a character string enclosed in delimiters (apostrophes or quotation marks). It takes one of the following forms:
Rules and Behavior
The value of a character constant is the string of characters between the delimiters. The value does not include the delimiters, but does include all blanks or tabs within the delimiters.
If a character constant is delimited by apostrophes, use two
consecutive apostrophes (
'' ) to place an apostrophe
character in the character constant.
Similarly, if a character constant is delimited by quotation marks, use two consecutive quotation marks ("") to place a quotation mark character in the character constant.
The length of the character constant is the number of characters between the delimiters, but two consecutive delimiters are counted as one character.
The length of a character constant must be in the range of 0 to 2000. Each character occupies one byte of memory.
If a character constant appears in a numeric context (such as an expression on the right side of an arithmetic assignment statement), it is considered a Hollerith constant.
A zero-length character constant is represented by two consecutive apostrophes or quotation marks.
The following examples demonstrate valid and invalid character constants:
| ||No trailing apostrophe.|
| ||Beginning delimiter does not match ending delimiter.|
For More Information:
For details on declaring data of type character, see Section 5.1.2.