nope. And I can confirm that there is no trailing null with or without adding it manually.
The possibility that there’s something weird happening with memory is there. Most of the C functions are done byref. I just set it all up so that instead of passing a variable within xojo from one method to another and then to the C function, I am setting two properties in the class instance of type cString with the parameter and value text in them - fgParam and fgValue. Then I am passing those properties to the external function. I get the same result though.
This is in a button that should set the exposure time to 250000:
var result as boolean = false
var cParam as CString = "ExposureTime"
var cValue as CString = "250000"
FrameGrabber.fgParam = cParam
FrameGrabber.fgValue = cValue
result = FrameGrabber.CXPSetCameraParam(FrameGrabber.fgParam,FrameGrabber.fgValue)
CXPSetCameraParam() - the internal method in my Xojo class. (not shown is the code that returns true or false based on the result)
//fgHandle = a property; the handle to the frame grabber that all calls must reference
//fgParam = a property; verified it contains the value set above
//fgValue = a property; verified it contains the value set above
var cameraParam as int32 = SetCameraParam(fgHandle, fgParam, fgValue)
SetCameraParam (The external method from the DLL)
Private Function SetCameraParam(byref fgHandle as int32, byref fgParam as cstring, byref fgValue as cstring) As Integer
And the actual C code from the DLL’s .h file:
// Change Camera Parameter Value
COAX_GRABBER_API int32_t SetCameraParam(int32_t * handle, char * param, char * value);
The difference now is that the error in the frame grabber’s logger is:
<Cannot decode byte '\x95': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream>
and it’s always x95, it doesn’t seem to change anymore.