-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WndProc/AddInputCharacter issue in Slovak layout. #6782
Comments
č is U+010D == 269 so that value is right. Your issue has to do with Win32 API supports of Unicode and UTF+8. I reckon you have the same issue as #5725. See our solution
Why not switching to Unicode? |
Well this does indeed fix the issue by using CreateWindowW even in MBCS mode, but is there any solution for Ascii? |
I think there could be some implementation done in ImGui for the ascii version, but I have no idea how to properly get this thing to even work. Changing the codepage to |
I don't know, you will need to dig (also check linked issues and other issues linked to it and to its commit). |
No idea if this is proper way of getting code page, but it seems to work for me. The code for getting codepage: HKL m_KeyboardLayout = GetKeyboardLayout(0);
LCID m_KeyboardLCID = MAKELCID(HIWORD(m_KeyboardLayout), SORT_DEFAULT);
unsigned int m_CodePage = CP_ACP;
GetLocaleInfoA(m_KeyboardLCID, LOCALE_RETURN_NUMBER | LOCALE_IDEFAULTANSICODEPAGE, (LPTSTR)&m_CodePage, sizeof(m_CodePage)); Using this with wndproc WM_INPUTLANGCHANGE will return proper codepage when switching layout. |
Closed by #6785 |
I've had in my back of my head that I wanted to look into this more since #6785 didn't quite pass the sniff test for me (for reasons similar to Omar's concerns raised on the PR.) I'm not confident using
Is the keyboard layout always the same as the current process code page? My instinct says no, but maybe that's the default? If it's only the default, I would be concerned the adopted fix will end up breaking apps manifested as UTF-8 since in those apps all the old-school ANSI stuff will be UTF-8 but it's unclear if that'd extend to the keyboard layout. (Would need to investigate further.) I could not find a 100% definitive API for getting the "process code page", I suspect that should actually probably read "thread code page", IE: I'd be interested in hearing whether using the old code with It'd also be worth checking if there's a disagreement between CPINFOEXW info = { };
::GetCPInfoExW(CP_ACP, 0, &info);
wprintf(L" CP_ACP: '%s'\n", info.CodePageName);
::GetCPInfoExW(CP_THREAD_ACP, 0, &info);
wprintf(L"CP_THREAD_ACP: '%s'\n", info.CodePageName); |
I did back then try to run GetCPInfoEx() on all meaningful defines including CP_THREAD_ACP and didn’t get any difference. |
This has been discussed in the pull request that it doesn't change anything. Also I mention there that I fixed it by changing the language for non-unicode programs in advanced language settings in windows settings, which seems weird to even use that approach if you want for example change keyboard layout on the fly and type in different language. |
Oops, I don't know how I missed/forgot that considering it was right at the start. Sorry about that! |
Version/Branch of Dear ImGui:
Version: 1.89.8
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler: MSVC (Multi-byte Character Set)
Operating System: Windows 10
My Issue/Question:
I got some issue with WndProc and I couldn't find anything at google or anyone having similar issue besides the russian input posted here as issue like year ago, but this issue is kinda weird. So first at all I have loaded correct font with glyph range that can display the characters I'm trying to type and I even tried to manually insert the utf-8 encoded characters that I tried to type and they display correctly. The issue is when I press "4" on top of my keyboard which translates to "č" in Slovak layout it is passed in WndProc as wparam of 232 which instead displaying as "č" it display as "è" even after MultiByteToWideChar conversion. When I add primitive if check before
io.AddInputCharacter
call to check if wch is 232 and change it to 269 it will always properly display the "č" character without any issue.Here are some characters typed on the Slovak layout on top keyboard from "1, 2, ... 0":
+¾šè�žýáíé
"+ľščťžýáíé
"I have no idea how to even solve this issue besides manually doing conversion to it and I still have no clue if this issue is present only on my system or anyone else.
The text was updated successfully, but these errors were encountered: