summaryrefslogtreecommitdiff
path: root/src/strutils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/strutils.cc')
-rw-r--r--src/strutils.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/strutils.cc b/src/strutils.cc
new file mode 100644
index 0000000..e7b7c93
--- /dev/null
+++ b/src/strutils.cc
@@ -0,0 +1,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