This is not right - the valueSize is the used as the size for byte buffer which is filled with words, not as the length of words in 2-byte characters.