-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the main binary a Unicode application on Windows
This commit uses "wide" (i.e. UTF-16) commandline arguments when launching the program on Windows, and uses the "wide" Windows APIs when dealing with strings. This makes it independent from the currently selected active code page on the system, and hopefully fixes issues with "nonstandard" characters appearing in file and directory paths. Fixes #172.
- Loading branch information
1 parent
9ffe337
commit 92246c3
Showing
8 changed files
with
73 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiled via msys2
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, console output will be borked - this is a separate issue. Things will (or, rather, should) work fine if you use the GUI. You can also try setting the MinGW console to UTF-8 and see if that fixes stuff, but keep in mind that it might break other applications that you run in that console.
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stopped running from Win10 64bit
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually expected - arguments in the standard console window are encoded using the ACP by the default, so there is no way to pass characters outside your ACP (which I'm now sure is Windows-1251 after seeing "Корпорация Майкрософт") even if the application is Unicode-aware.
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything is bad \8^(
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a look at this later on - have to admit I didn't even think of testing with the standard console, which is known to cause issues exactly like this. I don't think
chcp
is the answer here, but I might be wrong.92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure?
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your commit got into the nightly build it would be good to roll back and rebuild it because tsmuxer is used often from the console
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsMuxerGUI.exe from w64-nightly-2020-02-05--01-09-49.zip works great!
but tsMuxeR.exe from w64-nightly-2020-02-05--01-09-49.zip doesn't even start:
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI is starting, the output just isn't being given to cmd.exe. -mwindows is probably getting set somewhere when building the CLI, and that needs to be removed or appended with -mconsole (whichever is true, -mconsole needs to be last in the linker command). It's also a little sneaky because the dependencies can pop -mwindows into the linker (SDL is/was notorious for this, for example).
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namely, the lack of console output was probably directly linked to adding WIN32 to add_executable in tsmuxer/CMakeLists.txt. According to CMake documentation, passing
WIN32
to add_executable setsWIN32_EXECUTABLE
, and (via https://cmake.org/cmake/help/latest/prop_tgt/WIN32_EXECUTABLE.html#prop_tgt:WIN32_EXECUTABLE):Passing
-municode
intotarget_compile_options
and not passing WIN32 to add_executable might be the solution. In other apps where it's not possible to control whether the dependencies throw -mwindows into the linker command, the solution is just to brute-force -mconsole to the end of the command, since the last one will take precedence.92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole problem originates in
WinMain
, because I - for some reason - decided that it's necessary to use it in Windows Unicode builds instead of the standardint main
in order to have access to "wide" parameters, but this is actually not true. Since the command line is received viaGetCommandLineW()
anyway, it does not matter which entry point is used for the application.So, yes, the solution is to remove
WIN32
(without which I was - understandably - getting linking errors on MinGW) and restore "standard"main
as the program's main function, which makes the CRT properly allocate the console handles on Windows - as opposed toWinMain
, when little initialisation is done by the CRT in order to simulate a standard console application. I'll take care of this later today.92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But since now the tsMuxeR requires .meta in utf8, and many programs write it in 8-bit encoding, it is necessary ANNOUNCE this for save compatibility
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://forum.doom9.org/showthread.php?p=1898868#post1898868
92246c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xavery for the commit to work, I've had to add at the top of
file_win32.cpp
anddirectory.cpp:
Could you please advise if any alternative.
EDIT : sorry, forget about this... for whatever reason CMakeLists.txt was not referenced anymore in Visual Studio.