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

Summary: Getting unicode arguments for the main entry point on Windows
Product: SDL Reporter: Simon Hug <chli.hug>
Component: mainAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: Windows (All)   
Attachments: Patch that makes the main entry point on Windows use the GetCommandLine path of WinMain.

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