summaryrefslogtreecommitdiff
path: root/src/strutils.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2015-05-28 21:14:52 +0200
committerJoel Klinghed <the_jk@yahoo.com>2015-05-28 21:16:14 +0200
commit720295848ea0d909cb39c004cbeaf1055fa7cffc (patch)
tree3a4c0332f8145986ddfc1c83e89b9cf8a1491546 /src/strutils.cc
parent978bb2523f2eef42eca8dbe35e0ad351a4953aa7 (diff)
Start of CGI interface
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