mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 21:16:56 +00:00
Use fputws for outputting wide strings
Also adds fwide byte/wide orientation checking to verify streams are able to receive the character type in question. On Windows, the fwide calls are no-ops that pass through the second arg and optimize out the if statement entirely.
This commit is contained in:
parent
1235f0a24a
commit
8bd59ec936
@ -19,6 +19,7 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstddef> // for std::ptrdiff_t
|
#include <cstddef> // for std::ptrdiff_t
|
||||||
#include <cstring> // for std::memmove
|
#include <cstring> // for std::memmove
|
||||||
|
#include <cwchar>
|
||||||
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||||
# include <locale>
|
# include <locale>
|
||||||
#endif
|
#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) {
|
FMT_FUNC void vprint(std::FILE* f, wstring_view format_str, wformat_args args) {
|
||||||
wmemory_buffer buffer;
|
wmemory_buffer buffer;
|
||||||
internal::vformat_to(buffer, format_str, args);
|
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) {
|
FMT_FUNC void vprint(string_view format_str, format_args args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user