diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index fd87aaea8e..2d79c61f1c 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -165,7 +165,14 @@ bool DolphinApp::OnInit() void DolphinApp::ParseCommandLine() { auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions); - optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv); + + // Manually convert each argument to a UTF-8 std::string, because the implicit + // conversion of wxCmdLineArgsArray to char** calls ToAscii (which is undesired). + std::vector utf8_argv; + for (int i = 1; i < argc; ++i) + utf8_argv.emplace_back(argv[i].utf8_str()); + optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), utf8_argv); + std::vector args = parser->args(); if (options.is_set("exec")) diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp index 236cd86ba2..e8cdc6b3b6 100644 --- a/Source/Core/UICommon/CommandLineParse.cpp +++ b/Source/Core/UICommon/CommandLineParse.cpp @@ -105,17 +105,29 @@ std::unique_ptr CreateParser(ParserOptions options) return parser; } -optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv) +static void AddConfigLayer(const optparse::Values& options) { - optparse::Values& options = parser->parse_args(argc, argv); - const std::list& config_args = options.all("config"); - if (config_args.size()) + if (!config_args.empty()) { Config::AddLayer(std::make_unique( config_args, static_cast(options.get("video_backend")), static_cast(options.get("audio_emulation")))); } +} + +optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv) +{ + optparse::Values& options = parser->parse_args(argc, argv); + AddConfigLayer(options); + return options; +} + +optparse::Values& ParseArguments(optparse::OptionParser* parser, + const std::vector& arguments) +{ + optparse::Values& options = parser->parse_args(arguments); + AddConfigLayer(options); return options; } } diff --git a/Source/Core/UICommon/CommandLineParse.h b/Source/Core/UICommon/CommandLineParse.h index ffe2fc87ee..98a7da981a 100644 --- a/Source/Core/UICommon/CommandLineParse.h +++ b/Source/Core/UICommon/CommandLineParse.h @@ -3,6 +3,8 @@ // Refer to the license.txt file included. #include +#include +#include namespace optparse { @@ -20,4 +22,6 @@ enum class ParserOptions std::unique_ptr CreateParser(ParserOptions options); optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv); +optparse::Values& ParseArguments(optparse::OptionParser* parser, + const std::vector& arguments); }