utils: add ascii ctype helpers

Add some constexpr ctype helpers that avoid any possible UB (i.e.,
handling casting to unsigned), and explicitly avoid any
locale-specifics.
This commit is contained in:
Dirk-Jan C. Binnema
2026-07-21 13:21:09 +03:00
committed by Seth Ladygo
parent 39b7cf2e9d
commit f2960a197e
3 changed files with 169 additions and 1 deletions

View File

@ -269,7 +269,7 @@ Mu::remove_ctrl(const std::string& str)
result.reserve(str.length());
for (auto&& c : str) {
if (::iscntrl(c) || c == ' ') {
if (is_ascii_cntrl(c) || c == ' ') {
if (prev != ' ')
result += prev = ' ';
} else