string.format("%q", foo_str) will format a string to add the appropriate escape chars to make it safe to read back into the Lua interpreter. How can I best use this function to format a Lua_Buffer from the C-API? More generally, how can I access the string.* functions from the C-API? I could use lua_pcall("string.format", ...), but curious if there is a more direct way.
Asked
Active
Viewed 870 times
1 Answers
2
The format
function is defined as static in the lstrlib.c
module, so AFAIK the only way to get to it is through the string
table.
I suppose you could look at addquoted
in lstrlib.c
and adjust it for your use, but probably easier to just call string.format
.

Mud
- 28,277
- 11
- 59
- 92