NoGUI/Win32: Fix text input

This commit is contained in:
Connor McLaughlin 2022-09-09 13:30:53 +10:00
parent b4f2e297e9
commit aeb3d00002
1 changed files with 2 additions and 2 deletions

View File

@ -325,10 +325,10 @@ LRESULT CALLBACK Win32NoGUIPlatform::WndProc(HWND hwnd, UINT msg, WPARAM wParam,
{ {
if (ImGuiManager::WantsTextInput()) if (ImGuiManager::WantsTextInput())
{ {
const WCHAR utf16[2] = {static_cast<wchar_t>(wParam), 0}; const WCHAR utf16[1] = {static_cast<WCHAR>(wParam)};
char utf8[8] = {}; char utf8[8] = {};
const int utf8_len = const int utf8_len =
WideCharToMultiByte(CP_UTF8, 0, utf16, sizeof(utf16), utf8, sizeof(utf8) - 1, nullptr, nullptr); WideCharToMultiByte(CP_UTF8, 0, utf16, std::size(utf16), utf8, sizeof(utf8) - 1, nullptr, nullptr);
if (utf8_len > 0) if (utf8_len > 0)
{ {
utf8[utf8_len] = 0; utf8[utf8_len] = 0;