2.6. String Literals

[PREVIOUS][UP][NEXT]

A string literal is formed by a sequence of graphic characters (possibly none) enclosed between two quotation characters used as string brackets.

    string_literal ::= "{graphic_character}" 

A string literal has a value that is a sequence of character values corresponding to the graphic characters of the string literal apart from the quotation character itself. If a quotation character value is to be represented in the sequence of character values, then a pair of adjacent quotation characters must be written at the corresponding place within the string literal. (This means that a string literal that includes two adjacent quotation characters is never interpreted as two adjacent string literals.)

The length of a string literal is the number of character values in the sequence represented. (Each doubled quotation character is counted as a single character.)

Examples:

    "Message of the day:"   

    ""                     --  an empty string literal
    " "   "A"   """"       --  three string literals of length 1 

    "Characters such as $, %, and } are allowed in string literals"                                                   

Note:

A string literal must fit on one line since it is a lexical element (see 2.2). Longer sequences of graphic character values can be obtained by catenation of string literals. Similarly catenation of constants declared in the package ASCII can be used to obtain sequences of character values that include nongraphic character values (the so-called control characters). Examples of such uses of catenation are given below:

    "FIRST PART OF A SEQUENCE OF CHARACTERS " &
    "THAT CONTINUES ON THE NEXT LINE" 
    "sequence that includes the" & ASCII.ACK & "control character" 

References: package, catenation operation, character value, constant, declaration, end of a line, graphic character, lexical element.


[INDEX][CONTENTS]