A character constant is a string of printable ASCII characters enclosed by delimiters. It takes one of the following forms: [k_]'[c...]' [C] [k_]"[c...]" [C] k Is an optional kind type parameter (1 is the default). It must be followed by an underscore. c Is an ASCII character. C Is a C string specifier. If no kind type parameter is specified, the type is default character. The length of the character constant is the number of characters between the delimiters. In the apostrophe format, two consecutive apostrophes represent a single apostrophe. In the quotation mark format, two consecutive quotation marks represent a single quotation mark. The length of a character constant must be in the range 0 to 2000.
1 – C Strings
String values in the C language are terminated with null characters (CHAR(0)) and can contain nonprintable characters (such as a backspace). Nonprintable characters are specified by escape sequences. An escape sequence is denoted by using the backslash (\) as an escape character, followed by a single character indicating the nonprintable character desired. This type of string is specified by using a standard string constant followed by the character C. The standard string constant is then interpreted as a C-language constant. Backslashes are treated as escapes, and a null character is automatically appended to the end of the string (even if the string already ends in a null character). The following C-style escape sequences are allowed in character constants: Escape Sequence Represents --------------- ---------- \a or \A A bell \b or \B A backspace \f or \F A formfeed \n or \N A new line \r or \R A carriage return \t or \T A horizontal tab \v or \V A vertical tab \x"hh" or \X"hh" A hexadecimal bit pattern \"ooo" An octal bit pattern \0 A null character \\ A backslash If a character constant contains any other escape sequence, the backslash is ignored. A C string must also be a valid Fortran string. If the string is delimited by apostrophes, apostrophes in the string itself must be represented by two consecutive apostrophes (''). For example, the escape sequence \'string causes a compiler error because Fortran interprets the apostrophe as the end of the string. The correct form is \''string. If the string is delimited by quotation marks, quotation marks in the string itself must be represented by two consecutive quotation marks (""). The sequences \"ooo" and \x"hh" allow any ASCII character to be given as a one- to three-digit octal or a one- to two-digit hexadecimal character code. Each octal digit must be in the range 0 to 7, and each hexadecimal digit must be in the range 0 to F. For example, the C strings '\010'C and '\x08'C) both represent a backspace character followed by a null character. The C string '\\abcd'C) is equivalent to the string '\abcd' with a null character appended. The string ''C represents the ASCII null character.