luup.call_delay with string data not working

string with null char is not passed entirely with call_delay.

function ProcessMessage( psCommand )
luup.log("Process Msg : " … (psCommand))
end

luup.call_delay(“ProcessMessage”, 1 , “abc\000def”)

this produces the output: “abc”

this examples is a little out of context because I used a function to output a string as a row of hexadecimal bytes. I printed the string before call_delay and in the function. The string is definitely shortened in the call…

is this a bug?

Strings in Lua are zero-terminated.

Nope. From the Lua 5.1 manual section 2.1:

Strings in Lua can contain any 8-bit value, including embedded zeros, which can be specified as '\0'.

Whether the MCV luup.* functions honour this is another matter entirely…

thank you futzle, I thought I had read that somewhere…

oops, sorry. I mixed up my Zero-termination with 8-bit only strings.

Doing a bit of further reading, there are a number of the string manipulation fns that would need to be avoided, or carefully handled, (such as string.format) when working with strings containing Zero termination chars.

The luup.* fns are all written in C, so if there’s a problem here, it’s probably in the way the values are kept and/or worked on that side (pushstring vs pushlstring type stuff)

If you’d like to see it fixed, you can shoot a ticket into Bugs.micasaverde.com, but it’ll be quicker to work around the problem.