ValueWToChar
- Last UpdatedOct 29, 2026
- 2 minute read
ValueWToChar converts an array of 16-bit numeric values (also known as double-byte words) into pairs of Unicode characters and then returns those characters as a string.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
ValueWToChar |
String |
Synchronous |
Yes |
Supported |
Supported |
Supported |
Supported |
Supported |
Syntax
ValueWToChar("strTagArray",numQtdChars,optNumSwap)
strTagArray
The name of the array that contains the values to be converted, as well as the index of the starting position in the array. If the starting position index is not specified, the default is 0. Each value in the array should be an unsigned integer in the range from 0 through 65535.
Note: If this parameter is enclosed in quotes, the string literal will be used. Otherwise, the value of the tag/expression will be used.
numQtdChars
The number of values to be converted (minimum of 1), starting from the specified starting position.
optNumSwap
A numeric flag that causes the two bytes of each value to be swapped as they are converted:
|
Value |
Description |
|---|---|
|
0 |
Do not swap |
|
1 |
Swap the bytes |
This parameter is optional; if no value is specified, the default value is 0.
Return value
This function returns a string containing the converted values.
Notes
Each 16-bit numeric value is also known as a double-byte word. This function splits each word into two bytes and then converts each byte into a single Unicode character. As such, this function only supports 8-bit character codes — that is, character codes in the range from 0 (U+0000) through 255 (U+00FF). For character codes greater than 255, or when double-byte words are not needed, use the ValueToChar function instead.
Unicode character codes in the ranges from 0 (U+0000) through 31 (U+001F) and from 128 (U+0080) through 159 (U+009F) are control characters, not alphanumeric characters. In particular, 0 is a NUL character that will effectively end the string that is returned by this function.
Examples
These examples use the following array:
|
Position |
Actual Value |
Hexadecimal |
Characters |
|---|---|---|---|
|
0 |
19833 |
4D 79 |
M y |
|
1 |
21364 |
53 74 |
S t |
|
2 |
29289 |
72 69 |
r i |
|
3 |
28263 |
6E 67 |
n g |
|
4 |
11776 |
2E 00 |
. [NUL] |
Starting from position 0 and then converting one value, this function returns "My":
ValueWToChar("MyArray",1)
Starting from position 0 and then converting five values, this function returns "MyString.":
ValueWToChar("MyArray",5)
Starting from position 1 and then converting three values, this function returns "String":
ValueWToChar("MyArray[1]",3)
Starting from position 1, converting three values, and then swapping the bytes, this function returns "tSirgn":
ValueWToChar("MyArray[1]",3,1)