fix #6540: IOBuffer(s) only for ByteString, utf16(s) for binary data, and add is_valid_utf16(s)