| 43 | #endif |
| 44 | |
| 45 | inline void InitUTF8CLI(int& argc, char* argv[]) { |
| 46 | #if defined(_WIN32) |
| 47 | // Windows does not support UTF-8 argv so we have to manually acquire it |
| 48 | static std::vector<std::unique_ptr<char[]>> utf8Argv(argc); |
| 49 | LPWSTR commandLine = GetCommandLineW(); |
| 50 | LPWSTR* wideArgv = CommandLineToArgvW(commandLine, &argc); |
| 51 | for (int i = 0; i < argc; ++i) { |
| 52 | int byteSize = WideCharToMultiByte(CP_UTF8, 0, wideArgv[i], -1, nullptr, 0, nullptr, nullptr); |
| 53 | utf8Argv[i] = std::make_unique<char[]>(byteSize); |
| 54 | WideCharToMultiByte(CP_UTF8, 0, wideArgv[i], -1, utf8Argv[i].get(), byteSize, nullptr, nullptr); |
| 55 | argv[i] = utf8Argv[i].get(); |
| 56 | } |
| 57 | #else |
| 58 | // Nothing to do for other platforms |
| 59 | (void)argc; |
| 60 | (void)argv; |
| 61 | #endif |
| 62 | } |
| 63 | |
| 64 | inline FILE* fopenUTF8(const std::string& path, const std::string& mode) { |
| 65 | #if defined(_WIN32) |