Fixes and implement WideToUtf8 and Utf8ToWide from Minecraft.Server

* MessageBox now uses WideToUtf8. This fixes RUS and ES languages.
* Fixed OnButtonClicked.
This commit is contained in:
GabsPuNs
2026-06-14 17:26:03 -04:00
parent af54f74333
commit 3fff023cad
5 changed files with 100 additions and 52 deletions

View File

@@ -38,19 +38,15 @@ int SystemInterface_Win64::TranslateString(Rml::String& translated, const Rml::S
if (end != Rml::String::npos)
{
Rml::String key = input.substr(i + 1, end - i - 1);
int wlen = MultiByteToWideChar(CP_UTF8, 0, key.c_str(), (int)key.size(), nullptr, 0);
if (wlen > 0)
std::wstring wkey = utils.Utf8ToWide(key);
if (!wkey.empty())
{
std::wstring wkey(wlen, L'\0');
MultiByteToWideChar(CP_UTF8, 0, key.c_str(), (int)key.size(), &wkey[0], wlen);
LPCWSTR wstr = app.GetString(wkey);
if (wstr && wcslen(wstr) > 0)
{
int utf8len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
if (utf8len > 0)
std::string utf8 = utils.WideToUtf8(wstr);
if (!utf8.empty())
{
std::string utf8(utf8len - 1, '\0');
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &utf8[0], utf8len, nullptr, nullptr);
result += utf8;
count++;
}