2.11.7 TypedString Structure
A TypedString structure is used in certain ROPs in order to compact the string representation on the wire as much as possible.
StringType (1 byte): An enumeration. The value MUST be one of the following.
No string is present.
The string is empty.
Null-terminated 8-bit character string. The terminating null character is one zero byte.
Null-terminated reduced Unicode character string. The terminating null character is one zero byte.
Null-terminated Unicode character string. The terminating null character is 2 zero bytes.
String (optional) (4 bytes): If the StringType field is set to 0x02, 0x03, or 0x04, then this field MUST be present and in the format specified by the Type field. Otherwise, this field MUST NOT be present.
To produce a reduced Unicode string from an original Unicode string, the server first scans the original Unicode string and determines that every character has a value less than 0x100; in other words, that the high-order byte of every character, including the terminating null character, is zero. It then produces a reduced Unicode string that is exactly half the size of the original Unicode string by omitting all the high-order zero bytes, including that of the terminating null character.
To reproduce the original Unicode string from a reduced Unicode string, the server inserts a zero byte after each byte of the reduced Unicode string, doubling its size.