CharsToText ('Encoding'*, 'Value1', 'Value2', ...)
Arguments
|
'Encoding*' |
Character encoding, specification of the name or code page ID |
|
|
'Encoding*' = "ASCII" 'Encoding*' = 1252 |
ASCII character encoding as plain text (in quotation marks!) or Code page ID for ASCII |
|
|
'Encoding*' = "UTF-8" 'Encoding*' = 65001 |
UTF-8 character encoding as plain text (in quotation marks!) or Codepage ID for UTF-8 |
|
|
'Encoding*' = "UTF-16" 'Encoding*' = 1200 |
UTF-16 character encoding as plain text (in quotation marks!) or Codepage ID for UTF-16 |
|
|
'Value1'... 'Valuen' |
The decimal character code for each character according to the selected character encoding; Entries as numerical values or as analog signals |
|
Parameters ending with * are only evaluated once at the start of the acquisition.
Description
This function assembles text from individual character codes and outputs it (text signal). The individual character codes 'Value1' through 'Valuen' are passed to the function as numeric values based on a configurable encoding. The encodings ASCII, UTF-8 and UTF-16 as well as other valid codepage ids are supported. If a code page is not supported by the system, this will be indicated in the expression builder.
Each 'value' must correspond to a numeric value with a byte size that matches the minimum byte size of the encoding.
In ASCII and UTF-8, for example, each "value" corresponds to a single byte. In UTF-16, each 'value' corresponds to a 2-byte integer.
The number of characters to be concatenated in a string is limited to 999. Decimal codes are preferred, but hexadecimal codes are also supported (prefixed with 0x).
Generating readable text from sources which can only process numerical values is made easier by this function.
It makes sense to use analog signals to transmit the decimal character codes so that the characters can be changed during data acquisition.
Examples
For clarity, the character codes are entered here as numerical values. In the application, an analog signal can be assigned to each numeric code, which is used, for example, to transmit the code from the PLC. A combination of analog signals and hard-coded numerical codes is also possible)
|
Expression |
Result |
Comment |
|---|---|---|
|
CharsToText("ASCII", 105, 98, 97, 32, 65, 71) |
iba AG |
ASCII encoding, decimal |
|
CharsToText(1252,105,98,97,32,65,71) |
iba AG |
Code page 1252, decimal |
|
CharsToText("ASCII", 65, 66, 67) |
ABC |
ASCII encoding, decimal |
|
CharsToText("UTF-8", 65, 66, 67) |
ABC |
UTF-8 encoding, decimal |
|
CharsToText("UTF-8", 0xE2, 0x82, 0xAC) |
€ |
Euro symbol, UTF-8 encoding, hexadecimal |
|
CharsToText("UTF-8", 226, 130, 172) |
€ |
Euro symbol, UTF-8 encoding, decimal |
|
CharsToText("UTF-16", 8364) |
€ |
Euro symbol, UTF-16 encoding, decimal |
|
CharsToText(869, 213, 226) |
Ωθ |
Code page 869 (Greek alphabet), decimal |
|
CharsToText(869, 0xD5, 0xE2) |
Ωθ |
Code page 869 (Greek alphabet), hexadecimal |