language update: pl,lt,sv,de,nl,tr,lv
[enigma2.git] / lib / base / estring.cpp
index ce36a002934d2585bee90311c8e89c2d9435c7bc..dcba7705d7bc45d3ba8fe56519bbac8942fee86d 100644 (file)
@@ -1,6 +1,7 @@
+#include <algorithm>
+#include <cctype>
+#include <climits>
 #include <string>
-#include <ctype.h>
-#include <limits.h>
 #include <lib/base/eerror.h>
 #include <lib/base/encoding.h>
 #include <lib/base/estring.h>
@@ -27,9 +28,9 @@ std::string getNum(int val, int sys)
        char buf[12];
 
        if (sys == 10)
-               std::snprintf(buf, 12, "%i", val);
+               snprintf(buf, 12, "%i", val);
        else if (sys == 16)
-               std::snprintf(buf, 12, "%X", val);              
+               snprintf(buf, 12, "%X", val);           
        
        std::string res;
        res.assign(buf);
@@ -633,3 +634,12 @@ void makeUpper(std::string &s)
 {
        std::transform(s.begin(), s.end(), s.begin(), (int(*)(int)) toupper);
 }
+
+std::string replace_all(const std::string &in, const std::string &entity, const std::string &symbol)
+{
+       std::string out = in;
+       std::string::size_type loc = 0;
+       while (( loc = out.find(entity, loc)) != std::string::npos )
+       out.replace(loc, entity.length(), symbol);
+       return out;
+}