Hi, I have some binary data coming from the C world, which is given by some length and a char * data. I would like to access this data from Nim - if possible without copying. If I try to convert it like
let nimData = $data
I only get the portion of data up until the first NULL - no way to specify the actual known length. What is the correct way to wrap this?
var x = newString(cl)
copyMem(addr(x[0]), data, cl)
Without a copy is not possible, a string owns its data.
Also if you don't want to copy it you could just use cstring as cstring,
var a: cstring = "there are \0 and here \0"
echo ord(a[10])