A UTF-16 encoded unicode character string of n characters, space-padded just as STRING is. If n is omitted, the string is variable length to the size needed to contain the result of the cast or passed parameter. The optional locale specifies a valid unicode locale code, as specified in ISO standards 639 and 3166 (not needed if LOCALE is specified on the RECORD structure containing the field definition).
Type casting UNICODE to VARUNICODE, STRING, or DATA is allowed, while casting to any other type will first implicitly cast to STRING and then cast to the target value type.
The upper size limit for any UNICODE value is 4GB.
Fields can optionally have a LENGTHSIZE attribute to specify the number of bytes (1, 2, or 4) used to store a variable-length field's length prefix. The default is 4 bytes. This is useful for reducing memory usage for small variable-length UNICODE strings. If a longer string is assigned, it will be truncated.
Example:
UNICODE16 MyUNIString := U'1234567890ABCDEF';
// utf-16-encoded string
UNICODE4 MyUnicodeString := U'abcd';
// same as: (UNICODE)'abcd'
UNICODE_de5 MyUnicodeString_de := U'abcd\353';
// becomes 'abcdë' with a German locale
UNICODE_de5 MyUnicodeString_de5 := U'abcdë';
// same as previous example
OUTPUT(MyUNIString);
OUTPUT(MyUnicodeString);
OUTPUT(MyUnicodeString_de);
OUTPUT(MyUnicodeString_de5);