Clipboard SetRawData BYTES

Hi!

Coming from Java, I am new to Xojo, so please forgiv me, if I am overseeing the obvious…
So I have a MemoryBlock, which starts with 4 bytes holding the size and then the data itself.
Usually, the data is only a small amount, which means 2 or 3 of the leading size bytes are 00 00 00 00.

Clipboard.AddRawData acceppts only a string and is truncated after the size-byte because it thinks it is a null terminated string.
So what I am looking for is a wary to put the whole MemoryBlock into the clipboard.

This is some sample code (not pretty, just a prototype):

      Dim c as new Clipboard
      
      Dim mb as New MemoryBlock(0)
      Dim bs as New BinaryStream(mb)
      bs.WriteLong(128) // ToDo: Put the actual size into the fist 4 bytes. Put value 128 for first test.
      bs.Write(blobdata)
      bs.Close
      msgbox(str(mb.size))
      c.AddRawData(mb, type)
      c.Close

Thank you very much,
Bernhard

Here is sample code for you:

[code] // take some data
dim data as string = “Hello”

// make sure it uses the right encoding
data = ConvertEncoding(data, encodings.UTF8)

// make string with required
dim m as new MemoryBlock(4+lenb(data))
m.UInt32Value(0) = lenb(data)
m.StringValue(4,lenb(data)) = data

// stuff memoryblock in clipboard
dim c as new Clipboard
c.AddRawData(m, “test”)
[/code]