开发者

lua c api: how to push a string with a null character in the middle?

normally, I would just use

开发者_开发知识库lua_pushstring(lua_State* L, const char* s);

however, the string I want to push might have a null character in it. How do I make that work?


Use lua_pushlstring.

void lua_pushlstring (lua_State *L, const char *s, size_t len);

Pushes the string pointed to by s with size len onto the stack. Lua makes (or reuses) an internal copy of the given string, so the memory at s can be freed or reused immediately after the function returns. The string can contain embedded zeros.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜