utils: Introduce catv()

Tento commit je obsažen v:
2025-11-03 19:59:26 +01:00
rodič a31d88c7b3
revize ffa59d4b36
2 změnil soubory, kde provedl 26 přidání a 0 odebrání

Zobrazit soubor

@@ -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;
}

Zobrazit soubor

@@ -91,6 +91,8 @@ template <class T> inline std::string toString(const T &v)
}
std::string trim(std::string_view view);
std::string catv(std::string_view view);
} // namespace utils
#endif