通常,我会使用 lua_pushstring(lua_State* L, const char* s); 但是,我要推送的字符串可能包含空字符.我该如何工作? 使用 lua_pushlstring . void lua_pushlstring (lua_State *L, const char *s, size_t len); Pushes the
lua_pushstring(lua_State* L, const char* s);
但是,我要推送的字符串可能包含空字符.我该如何工作?
使用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.