UDF dstring has stored length in the last byte of buffer. Therefore last byte is not part of recorded characters. And empty string in dstring is encoded as empty buffer, including first byte (compression id).