With EcoStruxure Machine Expert V2.2 and later versions, the STRING data type can be encoded in Latin 1 or in UTF-8 format. For details, refer to the paragraphs Project-Wide UTF-8 Encoding and Encoding Single Literals in UTF-8 Format.
Since UTF-8 encoding provides the most comprehensive character set, it is a good practice to enable UTF-8 encoding for new projects, as well as for existing projects that are to be used in a new context.
EcoStruxure Machine Expert can process a wide variety of characters to display diagnostic messages or visualizations in different languages as well as to accept user input in these languages and characters or symbols.
If a comprehensive character set is not required or if a project is not subject to change, strings can be encoded in Latin 1 format. Additionally, the following character sets are supported:
|
Character set |
Code page number |
Description |
Character encoding |
|---|---|---|---|
|
20127 |
|
7-bit encoded character |
|
|
819, 850 |
|
8-bit encoded character |
|
|
28591 |
|
8-bit encoded character |
|
|
1252 |
|
8-bit encoded character |
|
|
- |
For more information, refer to https://home.unicode.org/. |
- |
|
|
Unicode 14.0 |
- |
144,697 characters |
- |
|
1200 |
|
16-bit encoded characters The characters are encoded either in 2 bytes or 4 bytes. |
|
|
UTF-8 |
65001 |
|
Tuple of 8-bit words per character The characters are encoded in different lengths from 1...4 bytes. |
The dialog box provides the parameter that allows you to configureUTF-8 encoding for all strings of data type STRING throughout the project. Refer to Project Settings - Compile Options in the Menu Commands Online Help.
WSTRING data types are not affected by this setting. They are always encoded as Unicode in UTF-16 format.
For data type STRING, project-wide encoding is as follows:
|
Option |
Project-wide encoding |
|---|---|
|
Selected |
UTF-8 |
|
Unselected |
|
With project-wide UTF-8 encoding enabled, STRING_TO conversion operators can be used as described under STRING_TO Conversions.
If project-wide UTF-8 encoding is enabled, then this setting also applies to library functions and add-ons.
If Latin 1 encoding is used throughout the project ( is unselected), you can encode single literals in UTF-8 format. To achieve this, add the UTF8# type prefix to each literal.
{attribute 'monitoring_encoding' := 'UTF-8'}
strVarUtf8: STRING := UTF8#'你好,世界!ÜüÄäÖö';
Example: A string variable in the OPC UA server will be converted to UTF-8 before being transferred to a client if the setting is not selected. This leads to values such as UTF8#'äöü' being misinterpreted.
A similar condition can occur with strings that are displayed in the visualization.
For further information, refer to