2222
2323#include < csignal>
2424
25- #include < QTextCodec>
2625#include < QApplication>
2726#include < QStyleHints>
2827#include < QQuickWindow>
3635
3736#include " log.h"
3837
39- #if (defined (_MSCVER) || defined (_MSC_VER))
40- #include < vector>
41- #include < algorithm>
42- #include < windows.h>
43- #include < shellapi.h>
44- #endif
45-
4638#ifndef MUSE_MODULE_DIAGNOSTICS_CRASHPAD_CLIENT
4739static void crashCallback (int signum)
4840{
@@ -85,10 +77,6 @@ int main(int argc, char** argv)
8577 // Setup global Qt application variables
8678 // ====================================================
8779
88- // Force the 8-bit text encoding to UTF-8. This is the default encoding on all supported platforms except for MSVC under Windows, which
89- // would otherwise default to the local ANSI code page and cause corruption of any non-ANSI Unicode characters in command-line arguments.
90- QTextCodec::setCodecForLocale (QTextCodec::codecForName (" UTF-8" ));
91-
9280 app_init_qrc ();
9381
9482 qputenv (" QT_STYLE_OVERRIDE" , " Fusion" );
@@ -143,43 +131,6 @@ int main(int argc, char** argv)
143131 QGuiApplication::setDesktopFileName (" org.musescore.MuseScore" MUSE_APP_INSTALL_SUFFIX);
144132#endif
145133
146- #if (defined (_MSCVER) || defined (_MSC_VER))
147- // // On MSVC under Windows, we need to manually retrieve the command-line arguments and convert them from UTF-16 to UTF-8.
148- // // This prevents data loss if there are any characters that wouldn't fit in the local ANSI code page.
149-
150- auto utf8_encode = [](const wchar_t * wstr) -> std::string
151- {
152- int size_needed = WideCharToMultiByte (CP_UTF8, 0 , &wstr[0 ], -1 , 0 , 0 , 0 , 0 );
153- std::string strTo (size_needed, 0 );
154- WideCharToMultiByte (CP_UTF8, 0 , &wstr[0 ], -1 , &strTo[0 ], size_needed, 0 , 0 );
155- return strTo;
156- };
157-
158- int argc_utf16 = 0 ;
159- wchar_t ** argv_utf16 = CommandLineToArgvW (GetCommandLineW (), &argc_utf16);
160- std::vector<std::string> argsUtf8; // store data
161- for (int i = 0 ; i < argc_utf16; ++i) {
162- argsUtf8.push_back (utf8_encode (argv_utf16[i]));
163- }
164-
165- std::vector<char *> argsUtf8_с; // convert to char*
166- for (std::string& arg : argsUtf8) {
167- argsUtf8_с.push_back (arg.data ());
168- }
169-
170- // Don't use the arguments passed to main(), because they're in the local ANSI code page.
171- Q_UNUSED (argc);
172- Q_UNUSED (argv);
173-
174- int argcFinal = argc_utf16;
175- char ** argvFinal = argsUtf8_с.data ();
176- #else
177-
178- int argcFinal = argc;
179- char ** argvFinal = argv;
180-
181- #endif
182-
183134 using namespace muse ;
184135 using namespace mu ::app;
185136
@@ -189,15 +140,15 @@ int main(int argc, char** argv)
189140#ifdef MUE_ENABLE_CONSOLEAPP
190141 CommandLineParser commandLineParser;
191142 commandLineParser.init ();
192- commandLineParser.parse (argcFinal, argvFinal );
143+ commandLineParser.parse (argc, argv );
193144
194145 IApplication::RunMode runMode = commandLineParser.runMode ();
195146 QCoreApplication* qapp = nullptr ;
196147
197148 if (runMode == IApplication::RunMode::AudioPluginRegistration) {
198- qapp = new QCoreApplication (argcFinal, argvFinal );
149+ qapp = new QCoreApplication (argc, argv );
199150 } else {
200- qapp = new QApplication (argcFinal, argvFinal );
151+ qapp = new QApplication (argc, argv );
201152 }
202153
203154 commandLineParser.processBuiltinArgs (*qapp);
0 commit comments