1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Formspec: add hypertext element

This commit is contained in:
Pierre-Yves Rollo 2019-09-10 15:11:26 +02:00 committed by SmallJoker
parent 8697090b35
commit 72416a6a1f
22 changed files with 1792 additions and 79 deletions

View file

@ -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;
}