diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/logging/backend.cpp | 4 | ||||
-rw-r--r-- | src/common/logging/text_formatter.cpp | 5 | ||||
-rw-r--r-- | src/common/string_util.cpp | 14 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d85e5837..0a081e7d 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -6,6 +6,7 @@ #include <array> #include <cstdio> +#include "common/assert.h" #include "common/common_funcs.h" // snprintf compatibility define #include "common/logging/backend.h" #include "common/logging/filter.h" @@ -78,8 +79,9 @@ const char* GetLevelName(Level log_level) { LVL(Warning); LVL(Error); LVL(Critical); + case Level::Count: + UNREACHABLE(); } - return "Unknown"; #undef LVL } diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 94f3dfc1..de195b0f 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -14,6 +14,7 @@ #include "common/logging/log.h" #include "common/logging/text_formatter.h" +#include "common/assert.h" #include "common/common_funcs.h" #include "common/string_util.h" @@ -82,6 +83,8 @@ void PrintColoredMessage(const Entry& entry) { color = FOREGROUND_RED | FOREGROUND_INTENSITY; break; case Level::Critical: // Bright magenta color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break; + case Level::Count: + UNREACHABLE(); } SetConsoleTextAttribute(console_handle, color); @@ -101,6 +104,8 @@ void PrintColoredMessage(const Entry& entry) { color = ESC "[1;31m"; break; case Level::Critical: // Bright magenta color = ESC "[1;35m"; break; + case Level::Count: + UNREACHABLE(); } fputs(color, stderr); diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index b2f7f7b1..6d6fc591 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -296,14 +296,28 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st std::string UTF16ToUTF8(const std::u16string& input) { +#if _MSC_VER >= 1900 + // Workaround for missing char16_t/char32_t instantiations in MSVC2015 + std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; + std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend()); + return convert.to_bytes(tmp_buffer); +#else std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; return convert.to_bytes(input); +#endif } std::u16string UTF8ToUTF16(const std::string& input) { +#if _MSC_VER >= 1900 + // Workaround for missing char16_t/char32_t instantiations in MSVC2015 + std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; + auto tmp_buffer = convert.from_bytes(input); + return std::u16string(tmp_buffer.cbegin(), tmp_buffer.cend()); +#else std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; return convert.from_bytes(input); +#endif } static std::string UTF16ToUTF8(const std::wstring& input) |