3.1.5 Character Data Type

The character data type can be specified as follows:

Is kind 1.
Is a string length (not a kind). For more information, see Section 5.1.2.

If no kind type parameter is specified, the kind of the constant is default character.

Character Constants

A character constant is a character string enclosed in delimiters (apostrophes or quotation marks). It takes one of the following forms:

 [k_]'ch[ch...]' [C]
 [k_]"ch[ch...]" [C]
Is the optional kind parameter: 1 (the default). It must be followed by an underscore ( _ ). Note that in character constants, the kind must precede the constant.
Is an ASCII character.
Is a C string specifier. C strings can be used to define strings with nonprintable characters. For more information, see Section

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:
'TODAY''S DATE IS: '    
"The average is: "    
Invalid  Explanation 
'HEADINGS   No trailing apostrophe. 
'Map Number:"   Beginning delimiter does not match ending delimiter. 

For More Information:

For details on declaring data of type character, see Section 5.1.2.

Previous Page Next Page Table of Contents