We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3452 - Getting unicode arguments for the main entry point on Windows
Summary: Getting unicode arguments for the main entry point on Windows
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: main (show other bugs)
Version: HG 2.0
Hardware: All Windows (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-14 09:59 UTC by Simon Hug
Modified: 2016-10-14 15:28 UTC (History)
0 users

See Also:


Attachments
Patch that makes the main entry point on Windows use the GetCommandLine path of WinMain. (2.32 KB, patch)
2016-10-14 09:59 UTC, Simon Hug
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Hug 2016-10-14 09:59:53 UTC
Created attachment 2583 [details]
Patch that makes the main entry point on Windows use the GetCommandLine path of WinMain.

There are currently three entry points in the SDL2_main code for windows: main, wmain and WinMain. Only the latter two properly convert the arguments to UTF-8.

Console applications linked with MSVC will always link with the main entry point (wmain has to be selected by manually setting the entry point). This makes it likely that such programs will not have proper unicode arguments.

The attached patch moves the GetCommandLine code out of WinMain in its own function so it can also be used by main. Additionally, the application exit code is now returned by WinMain.

I have done some minor testing, but plan to do some more.
Comment 1 Sam Lantinga 2016-10-14 15:28:03 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/e093aacd58a7