You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a very small issue that can be quickly fixed in no more than 5 minutes (I think :) ).
The problem is that when setting sub-window titles in multi-viewport mode in Windows,
the imgui binding program directly pass UTF-8 string to the system, where multi-byte characters is expected. This leads to incorrect title displaying when the input string is not ANSI C string.
The solution is inImGui_ImplWin32_SetWindowTitle funtion in imgui_impl_win32.cpp file, translate a UTF-8 string to UTF-16 wide char string and pass it to system by using ::SetWindowTextW(data->Hwnd, titlew); call. My solution would be like this:
static void ImGui_ImplWin32_SetWindowTitle(ImGuiViewport* viewport, const char* title)
{
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
IM_ASSERT(data->Hwnd != 0);
wchar_t titlew[260];
UTF8ToUTF16(titlew, 260, title); // Translate UTF-8 string to UTF-16
::SetWindowTextW(data->Hwnd, titlew); // And pass it to Windows.
}
Standalone, minimal, complete and verifiable example:
ImGui::Begin(u8"TTS测试");
// Some Stuff Here.
ImGui::End();
The text was updated successfully, but these errors were encountered:
Thank you @JX-Master, I have made a similar fix using Windows MultiByteToWideChar().
I have also confirmed that UTF-8 works as expected in the equivalent GLFW and SDL2 functions.
Version/Branch of Dear ImGui:
Version v1.66 WIP, Docking branch.
Back-end file/Renderer/OS: (or specify if you are using a custom engine back-end)
Back-ends: imgui_impl_d3d11.cpp + imgui_impl_win32.cpp
OS: Windows 10 (Simplified Chinese)
Compiler: MSVC 2017(v141)
My Issue/Question:
This is a very small issue that can be quickly fixed in no more than 5 minutes (I think :) ).
The problem is that when setting sub-window titles in multi-viewport mode in Windows,
the imgui binding program directly pass UTF-8 string to the system, where multi-byte characters is expected. This leads to incorrect title displaying when the input string is not ANSI C string.
The solution is in
ImGui_ImplWin32_SetWindowTitle
funtion inimgui_impl_win32.cpp
file, translate a UTF-8 string to UTF-16 wide char string and pass it to system by using::SetWindowTextW(data->Hwnd, titlew);
call. My solution would be like this:Standalone, minimal, complete and verifiable example:
The text was updated successfully, but these errors were encountered: