A string constant is a character string enclosed in single straight quotation marks. The characters are coded according to the character set specified in ISO/IEC 8859-1. Therefore, a string constant can include spaces and accented characters, as these belong to this character set. This is also referred to as a string literal, or simply a string.
Example: 'Hello world!'
When a dollar sign ($) is in a string constant, the following two characters are interpreted as a hexadecimal code according to the coding in ISO/IEC 8859-1. The code also corresponds to ASCII code. In addition, please note the special cases.
String with $ code |
Interpretation |
---|---|
|
8-bit code: Two-digit hexadecimal number that is interpreted according to ISO/IEC 8859-1. |
|
|
|
|
|
|
|
Control character: Line break (corresponds to '$R') |
|
Control character: New line (corresponds to '$L' and '$N') |
String with $ code |
Interpretation |
---|---|
|
Control character: Line feed (corresponds to |
|
Control character: New line (corresponds to |
|
Control character: Form feed |
|
Control character: Line break (corresponds to |
|
Control character: Tab |
|
Dollar sign: |
|
Single straight quotation mark: |
Example
Constant declaration
VAR CONSTANT constA : STRING := 'Hello world'; constB : STRING := 'Hello world $21'; // Hello world! END_VAR