With compiler version >= 3.5.18.0, UTF-8 encoded string literals are possible as a
single-byte string with base STRING
.
Syntax:
UTF8#' <string literal> '
Constant declaration
VAR CONSTANT constA : STRING := UTF8#'aäoöuü'; constB : STRING := UTF8#'Hello Allgäu $21'; // Hello Allgäu! END_VAR
To ensure correct monitoring, the 'monitoring_encoding' := 'UTF-8'
attribute can be added.
UTF-8 encoding only for project-wide configuration
UTF-8 encoding only for project-wide configuration
A UTF-8 encoding is used if the project-wide compile option “UTF8 encoding for STRING” is enabled. Library functions and add-ons are then also oriented according to this setting.
If you use single UTF-8 encoded strings, then you have to make sure that they are
interpreted correctly wherever they are used. For example, a string variable in the
OPC server will be converted to UTF-8 before being transferred to a client if the
setting is not selected. Values such as UTF8#'äöü'
would then be misinterpreted. Similar problems can arise when outputting strings
in the visualization.
-
See also: ⮫ 'monitoring_encoding' := 'UTF-8'