Merge pull request #9104 from JosJuice/cmd-unicode

DolphinQt: Handle non-ASCII characters in Windows cmd arguments
This commit is contained in:
Léo Lam
2020-10-20 01:45:28 +02:00
committed by GitHub
5 changed files with 48 additions and 25 deletions

View File

@ -31,6 +31,7 @@
#ifdef _WIN32
#include <Windows.h>
#include <shellapi.h>
constexpr u32 CODEPAGE_SHIFT_JIS = 932;
constexpr u32 CODEPAGE_WINDOWS_1252 = 1252;
#else
@ -630,3 +631,22 @@ std::string PathToString(const std::filesystem::path& path)
#endif
}
#endif
#ifdef _WIN32
std::vector<std::string> CommandLineToUtf8Argv(const wchar_t* command_line)
{
int nargs;
LPWSTR* tokenized = CommandLineToArgvW(command_line, &nargs);
if (!tokenized)
return {};
std::vector<std::string> argv(nargs);
for (size_t i = 0; i < nargs; ++i)
{
argv[i] = WStringToUTF8(tokenized[i]);
}
LocalFree(tokenized);
return argv;
}
#endif

View File

@ -236,3 +236,7 @@ inline bool IsPrintableCharacter(char c)
{
return std::isprint(c, std::locale::classic());
}
#ifdef _WIN32
std::vector<std::string> CommandLineToUtf8Argv(const wchar_t* command_line);
#endif