mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 12:20:43 +00:00
Slightly better sanitizeString variation
This commit is contained in:
parent
f9bf7a1010
commit
6c5b947ad5
@ -27,12 +27,20 @@ bool isAllowedPunctuation(char c)
|
||||
std::string sanitizeString(const std::string &input)
|
||||
{
|
||||
std::string output;
|
||||
bool inReplacement = false;
|
||||
|
||||
for (char c : input) {
|
||||
if (std::isalnum(static_cast<unsigned char>(c)) || isAllowedPunctuation(c)) {
|
||||
output += c;
|
||||
inReplacement = false;
|
||||
} else {
|
||||
if (!inReplacement) {
|
||||
output += '¿';
|
||||
inReplacement = true;
|
||||
}
|
||||
}
|
||||
// Else: skip (don't append)
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user