aboutsummaryrefslogtreecommitdiff
path: root/src/util/string.h
diff options
context:
space:
mode:
authorJean-Patrick Guerrero <kilbith@users.noreply.github.com>2020-03-07 14:01:11 +0100
committerGitHub <noreply@github.com>2020-03-07 14:01:11 +0100
commit0e88176db8ce9f3fb631feb56bdd29d4ada054f5 (patch)
treecf0fa004db32724677ae05ba82b77767165f7219 /src/util/string.h
parentce8cdc03337ac20b998620f2690eb76e5434ffb9 (diff)
downloadminetest-0e88176db8ce9f3fb631feb56bdd29d4ada054f5.tar.xz
GUIHyperText: Fix bug with UTF8 chars in action name + simplify UTF8 stringw conversion (#9437)
Co-authored-by: Pierre-Yves Rollo <dev@pyrollo.com>
Diffstat (limited to 'src/util/string.h')
-rw-r--r--src/util/string.h20
1 files changed, 14 insertions, 6 deletions
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());
+}