wsLiteral_TO_UTF8

This function converts any string of the data type WSTRING into a string in UTF-8 format. The function is particularly suitable for the assignment of literals.
When assigning literals to a UTF-8 STRING, the rules are:
- Literals that only use the ASCII character set can be directly assigned.
- Literals that use the STRING character set can be assigned by means of sLiteral_TO_UTF8().
- Literals that use the WSTRING character set can be assigned by means of wsLiteral_TO_UTF8().
An empty string will be returned if the literal is longer than the possible output string.
Return value
Name | Type | Description |
---|---|---|
wsLiteral_TO_UTF8 | STRING(511) | Converts any string of the data type WSTRING into a string in UTF-8 format. |
Inputs
VAR_IN_OUT CONSTANT
wsLiteral : WSTRING;
END_VAR
Name | Type | Description |
---|---|---|
wsLiteral | WSTRING | WSTRING to be converted. |
Examples
{attribute 'TcEncoding' := 'UTF-8'}
sMyText : STRING := wsLiteral_TO_UTF8("Hühner legen Eier.");
{attribute 'TcEncoding' := 'UTF-8'}
sMyText2 : STRING := wsLiteral_TO_UTF8("The dinner costs 30 €.");
![]() | Documentation for attribute 'TcEncoding' := 'UTF-8' For more information about strings in UTF-8 format see also the documentation on the 'TcEncoding' attribute. |
Requirements
Development environment | Target platform | PLC libraries to be integrated (category group) |
---|---|---|
TwinCAT v3.1.4022 | PC or CX (x86, x64, ARM) | Tc2_Utilities (System) >=3.3.34.0 |