Hello every one!
(I’m not good at English because I’'m Japanese…)
I want to use Japanese character in game title.
(Game Project)
On debugging, it is not garbled.
But on executable file (.exe) , it is garbled.
How can I use multi-byte characters in game title?
Please give me some solutions!!
1 Like
britzl
July 17, 2019, 6:00am
2
I’m not very familiar with Windows so I can’t say for sure what’s wrong. @Pkeod do you have any experience with this?
2 Likes
Pkeod
July 17, 2019, 7:32am
3
Could you test setting the game’s Window title with DefOS and see if it makes a difference?
2 Likes
Thank you for your reply!
I tried to use “defos”, but it is still garbled.
P.S. I want to use multi-byte characters not only in title bar but also in Android App name.
Is it depending on Defold system?
If so, I should wait for update!
britzl
July 17, 2019, 4:49pm
5
I believe we’ve had problems with non ascii characters in Android app names, but I think we solved it. @jhonny.goransson and @AGulev does that ring a bell?
1 Like
Pkeod
July 17, 2019, 4:50pm
6
Here’s the code for the DefOS version. I encourage you to search online for a possible solution and try to experiment on how it can be changed to work properly. Then contribute the improvement.
RECT rect = {0, 0, (int)w, (int)h};
DWORD style = (DWORD)get_window_style();
// TODO: we are assuming the window have no menu, maybe it is better to expose it as parameter later
AdjustWindowRect(&rect, style, false);
SetWindowPos(window, window, (int)x, (int)y, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
}
void defos_set_window_title(const char *title_lua)
{
SetWindowTextW(dmGraphics::GetNativeWindowsHWND(), CA2W(title_lua));
}
void defos_set_window_icon(const char *icon_path)
{
HANDLE icon = LoadImage(NULL, icon_path, IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
if (icon)
{
HWND window = dmGraphics::GetNativeWindowsHWND();
@ChaosYu @dapetcu21
3 Likes
Thanks!
I will try in various ways.
1 Like
I encountered this issue and I think I found a way to solve this. I added “CP_UTF8” to CA2W call and now my window title can show é in the title when it is set through DefOS.
void defos_set_window_title(const char *title_lua)
{
SetWindowTextW(dmGraphics::GetNativeWindowsHWND(), CA2W(title_lua, CP_UTF8));
}
britzl
August 9, 2022, 7:53pm
9
Hmm, I thought this was solved already? @Pkeod ?
Pkeod
August 10, 2022, 9:36pm
10
SetWindowTextW(dmGraphics::GetNativeWindowsHWND(), CA2W(title_lua));
Was the way it was done before it was fixed but without the CP_UTF8 parameter, which sounds like it should have been there.
This is what it is now
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);
@Hasan_Khan can you confirm you were using the latest version of DefOS / this version of it wasn’t working for you?
1 Like