summaryrefslogtreecommitdiff
path: root/src/util/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/string.cpp')
-rw-r--r--src/util/string.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp
index 388e8d293..caaef9b30 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -947,3 +947,28 @@ std::wstring translate_string(const std::wstring &s) {
translate_all(s, i, res);
return res;
}
+
+/**
+ * Create a std::string from a irr::core:stringw.
+ */
+std::string strwtostr(const irr::core::stringw &str)
+{
+ std::string text = core::stringc(str.c_str()).c_str();
+ return text;
+}
+
+/**
+ * Create a irr::core:stringw from a std::string.
+ */
+irr::core::stringw strtostrw(const std::string &str)
+{
+ size_t size = str.size();
+ // s.size() doesn't include NULL terminator
+ wchar_t *text = new wchar_t[size + sizeof(wchar_t)];
+ const char *data = &str[0];
+
+ mbsrtowcs(text, &data, size, NULL);
+
+ text[size] = L'\0';
+ return text;
+}