Skip to content

Migrate window class registration and window creation to Unicode APIs#1468

Merged
sylvessa merged 1 commit intosmartcmd:mainfrom
rucheykov:main
Apr 6, 2026
Merged

Migrate window class registration and window creation to Unicode APIs#1468
sylvessa merged 1 commit intosmartcmd:mainfrom
rucheykov:main

Conversation

@rucheykov
Copy link
Copy Markdown
Contributor

Description

Migrate window class registration and window creation from ANSI (RegisterClassA / CreateWindowA) to Unicode (RegisterClassW / CreateWindowW) APIs. This ensures proper handling of non-ASCII characters in text input.

Previous Behavior

Window class and windows were created using ANSI APIs.
WM_CHAR messages delivered characters encoded in the system code page, leading to incorrect display of non-ASCII text (e.g., Cyrillic, accented characters).

Root Cause

The use of ANSI APIs meant that character data was limited to the system code page. Non-ASCII input could not be represented correctly, resulting in garbage characters in text fields.

New Behavior

Window class registration and window creation now use Unicode APIs.
WM_CHAR messages now provide correct UTF-16 codepoints.
Non-ASCII characters are properly entered and displayed in text fields.

Fix Implementation

Replaced RegisterClassA with RegisterClassW and updated WNDCLASS/WNDCLASSEX structures to use wide-character strings.
Replaced CreateWindowA with CreateWindowW and ensured all string parameters are UTF-16 (L"...") literals.

Note: This will NOT solve the problem of entering Chinese and other characters; they simply aren't in the font. For that, we need to implement a fallback to GNU Unifont.
Note2: This is a remake of the request #950

Screenshot

2026-04-04_11-34

wcex.lpszClassName = "MinecraftClass";
wcex.lpszMenuName = L"Minecraft";
wcex.lpszClassName = L"MinecraftClass";
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_MINECRAFTWINDOWS));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt we want to make this LoadIconW too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt we want to make this LoadIconW too?

There will be no difference between ANSI and Unicode API in this case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair. just asked cause consistency

@sylvessa sylvessa merged commit b928351 into smartcmd:main Apr 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants