mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-05 13:14:45 +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 sanitizeString(const std::string &input)
|
||||||
{
|
{
|
||||||
std::string output;
|
std::string output;
|
||||||
|
bool inReplacement = false;
|
||||||
|
|
||||||
for (char c : input) {
|
for (char c : input) {
|
||||||
if (std::isalnum(static_cast<unsigned char>(c)) || isAllowedPunctuation(c)) {
|
if (std::isalnum(static_cast<unsigned char>(c)) || isAllowedPunctuation(c)) {
|
||||||
output += c;
|
output += c;
|
||||||
|
inReplacement = false;
|
||||||
|
} else {
|
||||||
|
if (!inReplacement) {
|
||||||
|
output += '¿';
|
||||||
|
inReplacement = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Else: skip (don't append)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user