Closed e1e5en-gd closed 2 years ago
What I see when testing, but it is different from before (which was garbled characters) so I'll assume it does work and just requires Russian / Chinese / etc. to be enabled in the OS for chars to properly display? I don't know enough about this to say.
Thank you for the patch!
What I see when testing, but it is different from before (which was garbled characters) so I'll assume it does work and just requires Russian / Chinese / etc. to be enabled in the OS for chars to properly display?
I don't think that's the case. When I tested the change in the engine itself I got it to show a Russian title on my Win 10.
@e1e5en-gd what did you test with?
@britzl, I tested on Windows 11.
If I'm not mistaken, then: • if the characters are displayed incorrectly, then this is a problem in the encoding; • if instead of characters one character is displayed (a question mark, for example), then the font does not support these characters.
@Subsoap, you can ask you to try in the project settings to change the name to a string with Russian characters "Привет, мир!". If the name is displayed correctly, then the problem is in my modifications. If question marks are displayed, then the system font may not support these characters.
@subsoap, you can ask you to try in the project settings to change the name to a string with Russian characters "Привет, мир!". If the name is displayed correctly, then the problem is in my modifications. If question marks are displayed, then the system font may not support these characters.
Good point. This would be a quick way of testing if it works or not!
Also tried on Windows 7:
I tried again with 192 beta but it's still the same for me.
But then I tried just setting the window title with 192 game.project and it does display properly. So there must be something missing or done wrong somewhere.
Setting the window title after this doesn't help, still shows as ???s for me.
Also
vs
I'll try to reproduce the error myself (I'll try to change the system language). Is it possible to somehow display values from the C++ extension to see what comes in the argument, how is the recoding done? I'm not very good at understanding how to work with the extension
@subsoap How does the previous version with CA2W
work with Russian characters?
In the above working example in Defold, the code is as follows:
wchar_t unicode_title[MAX_WINDOW_TITLE_LENGTH];
int res = MultiByteToWideChar(CP_UTF8, 0, title, -1, &unicode_title, MAX_WINDOW_TITLE_LENGTH);
if (res <= 0)
{
unicode_title[0] = 0;
}
(void) SetWindowTextW( _glfwWin.window, unicode_title );
When editing in the extension and transferring this code, I cursed at &
in the MultiByteToWideChar
function. As a result, the code is written like this:
wchar_t unicode_title[MAX_WINDOW_TITLE_LENGTH];
int res = MultiByteToWideChar(CP_UTF8, 0, title_lua, -1, unicode_title, MAX_WINDOW_TITLE_LENGTH);
if (res <= 0)
{
unicode_title[0] = 0;
}
SetWindowTextW(dmGraphics::GetNativeWindowsHWND(), unicode_title);
Now I decided to check and display the results that comes to the input and we get after the conversion. To do this, I use a MessageBox
and thought, suddenly converting LPCWSTR
is not enough (so I added it):
MessageBox(
NULL,
(LPCSTR)title_lua,
(LPCSTR)"Input",
MB_ICONINFORMATION | MB_OK | MB_DEFBUTTON1
);
wchar_t unicode_title[MAX_WINDOW_TITLE_LENGTH];
int res = MultiByteToWideChar(CP_UTF8, 0, title_lua, -1, unicode_title, MAX_WINDOW_TITLE_LENGTH);
if (res <= 0)
{
unicode_title[0] = 0;
}
MessageBoxW(
NULL,
unicode_title,
(LPCWSTR)L"Without (LPCWSTR)",
MB_ICONINFORMATION | MB_OK | MB_DEFBUTTON1
);
MessageBoxW(
NULL,
(LPCWSTR)unicode_title,
(LPCWSTR)L"With (LPCWSTR)",
MB_ICONINFORMATION | MB_OK | MB_DEFBUTTON1
);
SetWindowTextW(dmGraphics::GetNativeWindowsHWND(), (LPCWSTR)unicode_title);
My results are the following:
Unfortunately, there is no way I can reproduce the error that occurs. So I ask you to try. I'm not very good at C++. Sorry.
Changing parameter encoding when window title changes. Fix https://github.com/subsoap/defos/issues/126