STRING Constants

A STRING constant is a string enclosed by single quotation marks. The characters are encoded according to the Windows 1252 character set. As a subset of Windows-1252, the character set of ISO/IEC 8859-1 is supported. A STRING constant can contain blanks and umlauts, since these characters are part of the character set. It is also referred to as a character literal or simply a string.

Example:

'Hello World!'

If a STRING constant contains a dollar sign ($), the following two characters are interpreted as hexadecimal code according to the Windows-1252 coding. The code also corresponds to the ASCII code. Also note the special cases.

Hexadecimal code

String with $ code

Interpretation

$<8-bit code>

8-Bit code: two-digit hexadecimal number that is interpreted according to ISO/IEC 8859-1.

'$41'

A

'$A9'

©

'$40'

@

'$0D'

Control character line break, corresponds to '$R'.

'$0A'

Control character new line, corresponds to '$L' and '$SN'.

Special cases

String with $ code

Interpretation

'$L', '$l'

Control character line feed, corresponds to '$0A'.

'$N', '$n'

Control character new line, corresponds to $0A'.

'$P', '$p'

Control character form feed

'$R', '$r'

Control character line break, corresponds to '$0D'.

'$T', '$t'

Control character tab

'$$'

Dollar sign: $

'$''

Single quotation mark: '

Example: constant declaration

VAR CONSTANT
    sConstA : STRING := 'Hello Allgäu';
    sConstB : STRING := 'Hello Allgäu $21'; // Hello Allgäu!
END_VAR