The following code is ensuring that the data which is placed on the clipboard has a NUL terminator. I think the best way to do this is for now is to Encode the string as native, then if the last byte of the dataref isn't 0 (or the dataref is of zero length), make it mutable, append a zero byte and then return that one.