diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index f6fa29ab..bdafd5bb 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -19,6 +19,7 @@ #include #include // for std::ptrdiff_t #include // for std::memmove +#include #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) # include #endif @@ -977,7 +978,10 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) { FMT_FUNC void vprint(std::FILE* f, wstring_view format_str, wformat_args args) { wmemory_buffer buffer; internal::vformat_to(buffer, format_str, args); - internal::fwrite_fully(buffer.data(), sizeof(wchar_t), buffer.size(), f); + buffer.push_back(L'\0'); + if (std::fputws(buffer.data(), f) == -1) { + FMT_THROW(system_error(errno, "cannot write to file")); + } } FMT_FUNC void vprint(string_view format_str, format_args args) {