lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Recently I was manipulating wide character strings in a Lua library. Windows API assumes these strings to end with L'\0' which is represented as 2 successive zero bytes. The problem is, lua_tolstring guarantees only 1 zero byte at the end (according to the manual):

lua_tolstring returns a fully aligned pointer to a string inside the Lua state. This string always has a zero ('\0') after its last character (as in C), but can contain other zeros in its body.

If I solve this by appending L'\0' to strings (which is expensive operation), then I have problems to lua_concat such strings.

So I've a wish for Lua 5.2:
    "Make lua_tolstring guarantee 2 zero bytes at the string end".
It seems that no noticeable overhead would be incurred, and no compatibility issues would arise.

Please correct me if I'm wrong, or if better options exist.
Thanks.

--
Shmuel