mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Improved the StringUtil::toCapitalized function.
This commit is contained in:
parent
28a3beb9ce
commit
e6d6f3252f
|
@ -546,17 +546,19 @@ namespace Utils
|
||||||
std::string line {stringArg};
|
std::string line {stringArg};
|
||||||
bool active {true};
|
bool active {true};
|
||||||
|
|
||||||
for (int i = 0; line[i] != '\0'; ++i) {
|
for (auto& chr : line) {
|
||||||
if (std::isalpha(line[i])) {
|
if (std::isalnum(chr)) {
|
||||||
if (active) {
|
if (active) {
|
||||||
line[i] = Utils::String::toUpper(std::string(1, line[i]))[0];
|
chr = std::toupper(chr);
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
line[i] = Utils::String::toLower(std::string(1, line[i]))[0];
|
chr = std::tolower(chr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (line[i] == ' ' || line[i] == '\n' || line[i] == '\r' || line[i] == '\t')
|
else if (chr == ' ' || chr == '-' || chr == '\n' || chr == '\r' || chr == '\t') {
|
||||||
active = true;
|
active = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
|
|
Loading…
Reference in a new issue