From 05126d795ac1237a6bec1956723668a530a55432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20G=C3=B3rski?= Date: Fri, 2 Aug 2019 18:35:22 +0200 Subject: [PATCH] Code did not work with Windows compiler that had UNICODE support. Quick fix to make it work. --- rlutil.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rlutil.h b/rlutil.h index 24b6322..3b38f59 100644 --- a/rlutil.h +++ b/rlutil.h @@ -585,7 +585,16 @@ RLUTIL_INLINE void setString(RLUTIL_STRING_T str) { CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hConsoleOutput, &csbi); - WriteConsoleOutputCharacter(hConsoleOutput, str, len, csbi.dwCursorPosition, &numberOfCharsWritten); + + #if defined(UNICODE) || defined(_UNICODE) + int size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, NULL, 0); + TCHAR* tstr = (TCHAR*)malloc(size); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, tstr, size); + WriteConsoleOutputCharacter(hConsoleOutput, tstr, len, csbi.dwCursorPosition, &numberOfCharsWritten); + free(tstr); + #else + WriteConsoleOutputCharacter(hConsoleOutput, str, len, csbi.dwCursorPosition, &numberOfCharsWritten); + #endif #else // _WIN32 || USE_ANSI RLUTIL_PRINT(str); #ifdef __cplusplus