For WSTRING, the first two bytes at the given offset of the buffer are interpreted as the (little-endian-encoded or
big-endian-encoded, see above) WSTRING length (number of WCHARs), while each 2 following bytes in the buffer are
interpreted as a (little-endian-encoded or big-endian-encoded, see above) WCHAR in sequence. In the following example,
the bytes starting from offset 1 of the buffer get deserialized and give the WSTRING value wstr = "ab" with a
length of 2.
USING System.Serialization;
FUNCTION SerDe_Demo
VAR_TEMP
data : ARRAY[0..14] OF BYTE := [BYTE#16#0,
BYTE#16#2, BYTE#16#0, // little-endian-encoded length 2
BYTE#16#61, BYTE#16#0, // little-endian-encoded WCHAR "a"
BYTE#16#62, BYTE#16#0, // little-endian-encoded WCHAR "b"
BYTE#16#63, BYTE#16#0, // little-endian-encoded WCHAR "c"
BYTE#16#64, BYTE#16#0, // little-endian-encoded WCHAR "d"
BYTE#16#65, BYTE#16#0, // little-endian-encoded WCHAR "e"
BYTE#16#66, BYTE#16#0]; // little-endian-encoded WCHAR "f"
wstr : WSTRING;
nextValueOffset : INT;
END_VAR
// wstr = "ab"
// nextValueOffset = 7
nextValueOffset := Deserialize(1, data, wstr);
END_FUNCTION