]> git.stg.codes - stg.git/blobdiff - stglibs/common.lib/common.cpp
Added "smart" iconv 2nd arg const-ness detection.
[stg.git] / stglibs / common.lib / common.cpp
index 1068cfa12ed085351486dd462b844cc7603a4d73..22ec354b002442eab12f55b8868ddee7254669e8 100644 (file)
@@ -47,6 +47,8 @@
 
 #include <iconv.h>
 
+#include <algorithm>
+
 #include <cstdlib>
 #include <cstdarg>
 #include <cstdio>
@@ -820,6 +822,18 @@ std::string & Trim(std::string & val)
 return TrimR(TrimL(val));
 }
 //---------------------------------------------------------------------------
+std::string ToLower(std::string value)
+{
+    std::transform(value.begin(), value.end(), value.begin(), ::tolower);
+    return value;
+}
+//---------------------------------------------------------------------------
+std::string ToUpper(std::string value)
+{
+    std::transform(value.begin(), value.end(), value.begin(), ::toupper);
+    return value;
+}
+//---------------------------------------------------------------------------
 #ifdef WIN32
 static int is_leap(unsigned y)
 {
@@ -885,7 +899,7 @@ strncpy(inBuf, source.c_str(), source.length());
 
 inBuf[source.length()] = 0;
 
-#if defined(FREE_BSD) || defined(FREE_BSD5) || defined(WIN32)
+#if defined(CONST_ICONV)
 const char * srcPos = inBuf;
 #else
 char * srcPos = inBuf;