Skip to content

Commit c409c71

Browse files
authored
Merge pull request #3 from FreezeEngine/1.20.60
Fixes a crash when cyrillic present in paths to assets
2 parents 034ab64 + 000a1dd commit c409c71

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/Client/GUI/Engine/Engine.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,14 +2864,11 @@ void FlarialGUI::CopyBitmap(ID2D1Bitmap1* from, ID2D1Bitmap** to)
28642864
}
28652865

28662866
std::wstring FlarialGUI::to_wide(const std::string& str) {
2867-
std::wstring wstr;
2868-
wstr.reserve(str.length());
2869-
2870-
for (char ch : str) {
2871-
wstr.push_back(static_cast<wchar_t>(ch));
2872-
}
2873-
2874-
return wstr;
2867+
int wchars_num = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
2868+
std::wstring wide;
2869+
wide.resize(wchars_num);
2870+
MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, &wide[0], wchars_num);
2871+
return wide;
28752872
}
28762873
/*
28772874
std::wstring Lconst std::string& str)

0 commit comments

Comments
 (0)