Win32: define UNICODE so unsuffixed calls cannot fall back to the A functions, and share the UTF-8 conversion #186
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#186
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
claude/win32-titlemakes the Win32 window a Unicode one by calling the W functions by name (RegisterClassW,CreateWindowExW,DefWindowProcW,PeekMessageW,DispatchMessageW,SetWindowTextW).UNICODEand_UNICODEstay undefined:project.cpp:73(at852ae8a) defines onlyCRAFTER_GRAPHICS_WINDOW_WIN32. So every unsuffixed Win32 name in the library and the tests still means the A function, and nothing stops one from coming back. A new message loop written the usual way, withPeekMessageandDispatchMessage, would handWM_CHARover in the code page again, turning 日 and emoji into?.TextWin32catches that inStartSync's loop, not in a loop anywhere else.The same branch adds a file-static
Utf16FromUtf8toWindow.cpp, whileClipboard::SetTextdoes the same two-callMultiByteToWideCharinline (implementations/Crafter.Graphics-Clipboard.cpp:274-288) with a different failure check. Itsif (wlen < 0)(:276) can't fire, since the function returns 0 on failure.Suggested fix
UNICODEand_UNICODEbesideCRAFTER_GRAPHICS_WINDOW_WIN32. They reach every library unit,GamepadWin32.cand the tests, sinceLibraryTestcopiescfg.defines. The twoMessageBoxcalls withcharstrings then needL""orMessageBoxA.Window(SetTitle,WM_CHAR) andClipboard(SetText,GetText).