blob: e7b7c93e61a2ac018fa0656316e4b21377967e18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "common.hh"
#include "strutils.hh"
namespace stuff {
std::string ascii_tolower(const std::string& str) {
for (auto it = str.begin(); it != str.end(); ++it) {
if (*it >= 'A' && *it <= 'Z') {
std::string ret(str.begin(), it);
ret.push_back('a' + *it - 'A');
auto last = ++it;
while (it != str.end()) {
if (*it >= 'A' && *it <= 'Z') {
ret.append(last, it);
ret.push_back('a' + *it - 'A');
last = ++it;
} else {
++it;
}
}
ret.append(last, it);
return ret;
}
}
return str;
}
} // namespace stuff
|