diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/string.cpp | 25 | ||||
-rw-r--r-- | src/util/string.h | 20 |
2 files changed, 14 insertions, 31 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp index 2134fbd15..e6c52585d 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -860,28 +860,3 @@ 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; -} diff --git a/src/util/string.h b/src/util/string.h index 3aa11080f..0d2a6bdb2 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -726,11 +726,19 @@ inline std::string str_join(const std::vector<std::string> &list, } /** - * Create a std::string from a irr::core::stringw. + * Create a UTF8 std::string from a irr::core::stringw. */ -std::string strwtostr(const irr::core::stringw &str); +inline std::string stringw_to_utf8(const irr::core::stringw &input) +{ + std::wstring str(input.c_str()); + return wide_to_utf8(str); +} -/** - * Create a irr::core:stringw from a std::string. - */ -irr::core::stringw strtostrw(const std::string &str); + /** + * Create a irr::core:stringw from a UTF8 std::string. + */ +inline irr::core::stringw utf8_to_stringw(const std::string &input) +{ + std::wstring str = utf8_to_wide(input); + return irr::core::stringw(str.c_str()); +} |