]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/utils.cpp
Add move semantics to Variant
[libs/core.git] / source / strings / utils.cpp
index 6b659d0bd46a30a23f1a719dad1e79aa940a2678..748d717464690851585e22f9ccdc45da5885eabc 100644 (file)
@@ -1,7 +1,7 @@
-#include <algorithm>
 #include <list>
 #include <stdexcept>
 #include <cctype>
+#include <msp/core/algorithm.h>
 #include "utils.h"
 
 using namespace std;
@@ -63,14 +63,14 @@ int strcasecmp(const string &s1, const string &s2)
 string tolower(const string &str)
 {
        string result(str);
-       transform(result.begin(), result.end(), result.begin(), [](char c){ return std::tolower(c); });
+       transform(result, [](char c){ return std::tolower(c); });
        return result;
 }
 
 string toupper(const string &str)
 {
        string result(str);
-       transform(result.begin(), result.end(), result.begin(), [](char c){ return std::toupper(c); });
+       transform(result, [](char c){ return std::toupper(c); });
        return result;
 }
 
@@ -258,7 +258,7 @@ string c_escape(const string &str, bool escape_8bit)
                        result += "\\\'";
                else if(c=='\\')
                        result += "\\\\";
-               else if(static_cast<unsigned char>(c)<' ' || (escape_8bit && (c&0x80)))
+               else if(static_cast<unsigned char>(c)<' ' || c==0x7F || (escape_8bit && (c&0x80)))
                {
                        char buf[4] = { '\\', 0 };
                        for(unsigned j=0; j<3; ++j)