From 05ec2ac799eac5374e38d96ba871de16c93bfa59 Mon Sep 17 00:00:00 2001 From: erayhanoglu Date: Thu, 4 Aug 2016 19:51:13 +0300 Subject: [PATCH] Add unicode compiling support In unicode mode, WriteConsoleOutputCharacter is set to WriteConsoleOutputCharacterW which needs string as LPCWSTR. str_ has to be converted LPCWSTR value. --- rlutil.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rlutil.h b/rlutil.h index 24b6322..0401f95 100644 --- a/rlutil.h +++ b/rlutil.h @@ -573,8 +573,14 @@ RLUTIL_INLINE void locate(int x, int y) { /// Prints the supplied string without advancing the cursor #ifdef __cplusplus RLUTIL_INLINE void setString(const RLUTIL_STRING_T & str_) { +#ifdef _UNICODE + std::wstring stemp = std::wstring(str_.begin(), str_.end()); + LPCWSTR str = stemp.c_str(); + unsigned int len = str_.size(); +#else const char * const str = str_.data(); - unsigned int len = str_.size(); + unsigned int len = str_.size(); +#endif #else // __cplusplus RLUTIL_INLINE void setString(RLUTIL_STRING_T str) { unsigned int len = strlen(str);