correctly handle unicode args on win32

Fixes #1810
This commit is contained in:
itsmattkc
2021-12-29 00:12:23 -08:00
parent e902507e47
commit 82df30586d
5 changed files with 26 additions and 8 deletions
+17 -1
View File
@@ -71,6 +71,22 @@ int main(int argc, char *argv[])
// Parse command line arguments
//
QVector<QString> args;
#if defined(_WIN32) && defined(UNICODE)
int wargc;
LPWSTR *wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
args.resize(wargc);
for (int i=0; i<wargc; i++) {
args[i] = QString::fromWCharArray(wargv[i]);
}
LocalFree(wargv);
#else
args.resize(argc);
for (int i=0; i<argc; i++) {
args[i] = QString::fromLocal8Bit(argv[i]);
}
#endif
olive::Core::CoreParams startup_params;
CommandLineParser parser;
@@ -130,7 +146,7 @@ int main(int argc, char *argv[])
// Hidden crash option for debugging the crash handling
auto crash_option = parser.AddOption({QStringLiteral("-crash")}, QString(), true, QString(), true);
parser.Process(argc, argv);
parser.Process(args);
if (help_option->IsSet()) {
// Show help