add utf8.escape_xml and alias - string.escape_xml

This commit is contained in:
MihailRis
2025-11-23 19:52:49 +03:00
parent 91cb5ab7d8
commit 6810f9a03a
4 changed files with 37 additions and 0 deletions
+6
View File
@@ -88,6 +88,11 @@ static int l_escape(lua::State* L) {
return lua::pushstring(L, util::escape(string));
}
static int l_escape_xml(lua::State* L) {
auto string = lua::require_lstring(L, 1);
return lua::pushstring(L, util::escape_xml(string));
}
const luaL_Reg utf8lib[] = {
{"tobytes", lua::wrap<l_tobytes>},
{"tostring", lua::wrap<l_tostring>},
@@ -98,5 +103,6 @@ const luaL_Reg utf8lib[] = {
{"lower", lua::wrap<l_lower>},
{"encode", lua::wrap<l_encode>},
{"escape", lua::wrap<l_escape>},
{"escape_xml", lua::wrap<l_escape_xml>},
{nullptr, nullptr}
};