From 9a395a45d3a1ff64fff755be6bbb1aecf5bb9ff7 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 22 Mar 2017 00:59:34 +0100 Subject: [PATCH] Fix convertArgsToUtf8() --- application/commandlineutils.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/commandlineutils.cpp b/application/commandlineutils.cpp index 8ce5790..45ec610 100644 --- a/application/commandlineutils.cpp +++ b/application/commandlineutils.cpp @@ -69,6 +69,7 @@ void startConsole() setvbuf(stderr, NULL, _IONBF, 0); #ifdef CPP_UTILITIES_FORCE_UTF8_CODEPAGE // set console to handle UTF-8 IO correctly + // however, this doesn't work as intended and is therefore disabled by default SetConsoleCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8); #endif @@ -92,14 +93,14 @@ pair >, vector > convertArgsToUtf8() res.first.reserve(static_cast(argc)); res.second.reserve(static_cast(argc)); - for(; argv_w; ++argv_w) { - int requiredSize = WideCharToMultiByte(CP_UTF8, 0, *argv_w, -1, nullptr, 0, 0, 0); + for(LPWSTR *i = argv_w, *end = argv_w + argc; i != end; ++i) { + int requiredSize = WideCharToMultiByte(CP_UTF8, 0, *i, -1, nullptr, 0, 0, 0); if(requiredSize <= 0) { break; // just stop on error } auto argv = make_unique(static_cast(requiredSize)); - requiredSize = WideCharToMultiByte(CP_UTF8, 0, *argv_w, -1, argv.get(), requiredSize, 0, 0); + requiredSize = WideCharToMultiByte(CP_UTF8, 0, *i, -1, argv.get(), requiredSize, 0, 0); if(requiredSize <= 0) { break; }