diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h index be3d80a2..6d95ed33 100644 --- a/include/spdlog/sinks/wincolor_sink-inl.h +++ b/include/spdlog/sinks/wincolor_sink-inl.h @@ -145,8 +145,14 @@ void SPDLOG_INLINE wincolor_sink::print_range_(const memory_buf_t { if (end > start) { - auto size = static_cast(end - start); - auto ignored = ::WriteConsoleA(static_cast(out_handle_), formatted.data() + start, size, nullptr, nullptr); + auto size = end - start; +#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT + wmemory_buf_t buf; + details::os::utf8_to_wstrbuf(string_view_t(formatted.data() + start, size), buf); + auto ignored = ::WriteConsoleW(static_cast(out_handle_), buf.data(), static_cast(buf.size()), nullptr, nullptr); +#else + auto ignored = ::WriteConsoleA(static_cast(out_handle_), formatted.data() + start, static_cast(size), nullptr, nullptr); +#endif (void)(ignored); } }