aboutsummaryrefslogtreecommitdiff
path: root/src/util/string.h
diff options
context:
space:
mode:
authorMinetest-j45 <55553015+Minetest-j45@users.noreply.github.com>2021-08-30 15:22:40 +0100
committerGitHub <noreply@github.com>2021-08-30 15:22:40 +0100
commit7824a4956bf489b4e2cc35e0c97272eee06be6ba (patch)
tree70243765dc1743a83596f9c6eec122fb417ef92c /src/util/string.h
parent607add326feb44e078b843464ce4a8de09f28743 (diff)
parent35445d24f425c6291a0580b468919ca83de716fd (diff)
downloaddragonfireclient-7824a4956bf489b4e2cc35e0c97272eee06be6ba.tar.xz
Merge pull request #1 from EliasFleckenstein03/master
update
Diffstat (limited to 'src/util/string.h')
-rw-r--r--src/util/string.h44
1 files changed, 11 insertions, 33 deletions
diff --git a/src/util/string.h b/src/util/string.h
index 6fd11fadc..21f1d6877 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -64,22 +64,14 @@ struct FlagDesc {
u32 flag;
};
-// try not to convert between wide/utf8 encodings; this can result in data loss
-// try to only convert between them when you need to input/output stuff via Irrlicht
+// Try to avoid converting between wide and UTF-8 unless you need to
+// input/output stuff via Irrlicht
std::wstring utf8_to_wide(const std::string &input);
std::string wide_to_utf8(const std::wstring &input);
-wchar_t *utf8_to_wide_c(const char *str);
-
-// NEVER use those two functions unless you have a VERY GOOD reason to
-// they just convert between wide and multibyte encoding
-// multibyte encoding depends on current locale, this is no good, especially on Windows
-
// You must free the returned string!
-// The returned string is allocated using new
-wchar_t *narrow_to_wide_c(const char *str);
-std::wstring narrow_to_wide(const std::string &mbs);
-std::string wide_to_narrow(const std::wstring &wcs);
+// The returned string is allocated using new[]
+wchar_t *utf8_to_wide_c(const char *str);
std::string urlencode(const std::string &str);
std::string urldecode(const std::string &str);
@@ -353,11 +345,6 @@ inline s32 mystoi(const std::string &str, s32 min, s32 max)
return i;
}
-
-// MSVC2010 includes it's own versions of these
-//#if !defined(_MSC_VER) || _MSC_VER < 1600
-
-
/**
* Returns a 32-bit value reprensented by the string \p str (decimal).
* @see atoi(3) for further limitations
@@ -367,17 +354,6 @@ inline s32 mystoi(const std::string &str)
return atoi(str.c_str());
}
-
-/**
- * Returns s 32-bit value represented by the wide string \p str (decimal).
- * @see atoi(3) for further limitations
- */
-inline s32 mystoi(const std::wstring &str)
-{
- return mystoi(wide_to_narrow(str));
-}
-
-
/**
* Returns a float reprensented by the string \p str (decimal).
* @see atof(3)
@@ -387,8 +363,6 @@ inline float mystof(const std::string &str)
return atof(str.c_str());
}
-//#endif
-
#define stoi mystoi
#define stof mystof
@@ -696,15 +670,19 @@ inline const std::string duration_to_string(int sec)
std::stringstream ss;
if (hour > 0) {
- ss << hour << "h ";
+ ss << hour << "h";
+ if (min > 0 || sec > 0)
+ ss << " ";
}
if (min > 0) {
- ss << min << "m ";
+ ss << min << "min";
+ if (sec > 0)
+ ss << " ";
}
if (sec > 0) {
- ss << sec << "s ";
+ ss << sec << "s";
}
return ss.str();