summaryrefslogtreecommitdiff
path: root/examples/common.cpp
diff options
context:
space:
mode:
authorPavol Rusnak <pavol@rusnak.io>2023-04-11 21:45:44 +0200
committerGitHub <noreply@github.com>2023-04-11 19:45:44 +0000
commit8b679987cdce292ff36bd741f6715e4927e26f9b (patch)
treef6b913d90283ec662004818846e0a14357c0209e /examples/common.cpp
parent3e6e70d8e8917b5bd14c7c9f9b89a585f1ff0b31 (diff)
Fix whitespace, add .editorconfig, add GitHub workflow (#883)
Diffstat (limited to 'examples/common.cpp')
-rw-r--r--examples/common.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/common.cpp b/examples/common.cpp
index f909eed2..91d96efa 100644
--- a/examples/common.cpp
+++ b/examples/common.cpp
@@ -22,9 +22,9 @@ extern "C" __declspec(dllimport) int __stdcall GetConsoleMode(void* hConsoleHand
extern "C" __declspec(dllimport) int __stdcall SetConsoleMode(void* hConsoleHandle, unsigned long dwMode);
extern "C" __declspec(dllimport) int __stdcall SetConsoleCP(unsigned int wCodePageID);
extern "C" __declspec(dllimport) int __stdcall SetConsoleOutputCP(unsigned int wCodePageID);
-extern "C" __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags,
- const wchar_t * lpWideCharStr, int cchWideChar,
- char * lpMultiByteStr, int cbMultiByte,
+extern "C" __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags,
+ const wchar_t * lpWideCharStr, int cchWideChar,
+ char * lpMultiByteStr, int cbMultiByte,
const char * lpDefaultChar, bool * lpUsedDefaultChar);
#define CP_UTF8 65001
#endif
@@ -328,9 +328,9 @@ void win32_console_init(bool enable_color) {
// Convert a wide Unicode string to an UTF8 string
void win32_utf8_encode(const std::wstring & wstr, std::string & str) {
- int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
- std::string strTo(size_needed, 0);
- WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
- str = strTo;
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
+ std::string strTo(size_needed, 0);
+ WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
+ str = strTo;
}
#endif