utils: Introduce catv()

这个提交包含在:
2025-11-03 19:59:26 +01:00
父节点 a31d88c7b3
当前提交 ffa59d4b36
修改 2 个文件,包含 26 行新增0 行删除

查看文件

@@ -214,3 +214,27 @@ std::string utils::trim(std::string_view view)
}
return std::string{view};
}
std::string utils::catv(std::string_view view)
{
std::string result;
result.reserve(view.length());
for(auto c : view)
{
if (!isascii(c))
{
result += "M-";
result += toascii(c);
}
else if(iscntrl(c))
{
result += '^';
result += c == '\177' ? '?': c | 0100;
}
else
{
result += c;
}
}
return result;
}