Fix passing special characters to console-mode launcher on Windows#180
Conversation
840b25a to
a5ba595
Compare
|
@jcfr how can we create a new AppLauncher release after we merge this? |
|
The CD workflow gets triggered on the creation of a GitHub release as of 91f3d8e. Or manually triggered by specifying a tag and running the workflow through workflow dispatch. |
There was a problem hiding this comment.
Pull request overview
This pull request fixes special character handling in Windows console-mode launcher by ensuring command-line arguments are consistently converted to UTF-8 encoding on Windows across all launcher modes (console and GUI).
Changes:
- Added wmain entry point for Windows console launcher to properly handle wide-character arguments
- Refactored argument conversion logic to use shared helper functions
- Introduced platform-specific encoding/decoding helpers in ctkAppArguments for consistent UTF-8 handling on Windows
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Main.cpp | Added wmain entry point for Windows console mode with proper UTF-8 argument conversion; refactored cleanup to use deleteUnixArguments |
| Base/ctkCommandLineParser.h | Added overload for convertWindowsCommandLineToUnixArguments and deleteUnixArguments function declarations |
| Base/ctkCommandLineParser.cpp | Implemented helper functions for UTF-8 conversion, refactored existing conversion logic to reuse helpers, added cleanup function |
| Base/ctkAppArguments.cpp | Added platform-specific decodeArgument/encodeArgument helpers to ensure consistent UTF-8 handling on Windows |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
To follow-up on @jamesobutler comment, the release pipeline should be fully automated :) |
a5ba595 to
bf7c6d5
Compare
Awesome! Thanks for the responses @jamesobutler and @jcfr. I've found the build binaries in the CI artifacts and tested that everything works well on Windows now! |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bf7c6d5 to
256c643
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
Base/ctkCommandLineParser.cpp:978
- In convertWindowsCommandLineToUnixArguments(), the early guard returns before initializing *argc/*argv when cmd_line is null. Callers (e.g., wWinMain) pass uninitialized locals and appLauncherMain later reads argv[0], so this can lead to undefined behavior/crash. Consider always setting *argc = 0 and *argv = nullptr first, and if cmd_line is null fall back to returning at least argv[0] (empty or module filename).
void ctkCommandLineParser::convertWindowsCommandLineToUnixArguments(PWSTR cmd_line, int* argc, char*** argv)
{
if (!cmd_line || !argc || !argv)
{
return;
}
*argc = 0;
*argv = nullptr;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
256c643 to
ea1fae8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Base/ctkCommandLineParser.h
Outdated
| * to an empty string. | ||
| * | ||
| * @note The first argument (the executable path) will be set from the executable | ||
| * path determined by ::GetModuleFileNameW. The original value of argv[0] is not used. |
There was a problem hiding this comment.
The documentation incorrectly refers to "argv[0]" when it should refer to "wideArgv[0]". The parameter "argv" is an output parameter (where the converted arguments are stored), while "wideArgv" is the input parameter. The comment should read: "The original value of wideArgv[0] is not used."
| * path determined by ::GetModuleFileNameW. The original value of argv[0] is not used. | |
| * path determined by ::GetModuleFileNameW. The original value of wideArgv[0] is not used. |
Special characters in command-line arguments on Windows were only converted correctly in the non-console launcher. Now on Windows, command-line arguments are always converted to classic unix-style argc/argv with UTF-8 encoding.
ea1fae8 to
b7d59d7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@lassoan Full release steps are documented at the following below including updating the CMakeLists.txt with the bumped version corresponding to the new tag that is then created. |
|
I assumed that's the old manual process :( |

Special characters in command-line arguments on Windows were only converted correctly in the non-console launcher. Now on Windows, command-line arguments are always converted to classic unix-style argc/argv with UTF-8 encoding.