| Summary: | Always use Unicode on Windows | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Nathaniel J Fries <nfries88> |
| Component: | *don't know* | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | ||
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | Windows (All) | ||
|
Description
Nathaniel J Fries
2013-08-29 12:35:55 UTC
Additionally, you're treating wchar_t/WCHAR/WSTR as UCS-2-INTERNAL. It's actually UTF-16LE, even if Windows support for it isn't perfectly consistent yet. Windows does, in fact, handle Window input outside the BMP (codepoint > U+FFFF), as it is necessary to represent a character set required by law to be used in Chinese government documents. See: http://msdn.microsoft.com/en-us/library/windows/desktop/dd374081%28v=vs.85%29.aspx Also, there are two related errors in src/video/windows/SDL_windowsevents.c 1: Handling WM_KEYDOWN ToUnicode is used improperly. ToUnicode fills a buffer of type WCHAR with the UTF-16 representation of the current keyboard input, if it is in fact character input. Not only is this buffer wrongly treated as UTF-32, but the use of the function ignores the possibility that the input may require more than one codepoint to encode the current input character (in fact, it may require several, depending on the input language). Best to use a buffer that can hold at least 8 code units (i.e., WCHAR buffer[8]). http://msdn.microsoft.com/en-us/library/windows/desktop/ms646320%28v=vs.85%29.aspx 2: Handling WM_CHAR Similarly to WM_KEYDOWN, WM_CHAR improperly treats the character as UTF-32. In Unicode-enabled windows (Windows created with CreateWindowW), wParam would be UTF-16. In ANSI windows, wParam would have the associated ANSI encoding. http://msdn.microsoft.com/en-us/library/windows/desktop/ms646276%28v=vs.85%29.aspx I agree, this would be a good change. Do you already have a proposed patch? FYI, I committed fixes which make SDL use UNICODE by default, and UTF-16LE for string conversion. The windows message handling isn't fixed yet, so I'm leaving this bug open. Thanks for the good info! |