Enable mojibake

This commit is contained in:
Victor Zverovich 2019-12-24 08:20:54 -08:00
parent 9f6434dcde
commit 5390e29d42
2 changed files with 13 additions and 8 deletions

View File

@ -1507,15 +1507,14 @@ inline std::basic_string<Char> format(const S& format_str, Args&&... args) {
{internal::make_args_checked<Args...>(format_str, args...)});
}
FMT_API void vprint(string_view format_str, format_args args);
FMT_API void vprint(std::FILE* f, string_view format_str, format_args args);
FMT_API void vprint_mojibake(std::FILE* f, string_view format_str,
format_args args);
FMT_API void vprint(string_view, format_args);
FMT_API void vprint(std::FILE*, string_view, format_args);
FMT_API void vprint_mojibake(std::FILE*, string_view, format_args);
/**
\rst
Prints formatted data to the file *f*. For wide format strings,
*f* should be in wide-oriented mode set via ``fwide(f, 1)``.
Prints formatted data to the file *f*. For wide format strings *f* should be
in wide-oriented mode set via ``fwide(f, 1)``.
**Example**::
@ -1525,8 +1524,13 @@ FMT_API void vprint_mojibake(std::FILE* f, string_view format_str,
template <typename S, typename... Args,
FMT_ENABLE_IF(internal::is_string<S>::value)>
inline void print(std::FILE* f, const S& format_str, Args&&... args) {
#if !defined(_WIN32) || FMT_UNICODE
vprint(f, to_string_view(format_str),
internal::make_args_checked<Args...>(format_str, args...));
#else
vprint_mojibake(f, to_string_view(format_str),
internal::make_args_checked<Args...>(format_str, args...));
#endif
}
/**

View File

@ -21,7 +21,7 @@
# include <locale>
#endif
#if FMT_UNICODE
#ifdef _WIN32
# include <io.h>
# include <windows.h>
#endif
@ -1345,7 +1345,7 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) {
memory_buffer buffer;
internal::vformat_to(buffer, format_str,
basic_format_args<buffer_context<char>>(args));
#if defined(_WIN32) && FMT_UNICODE
#ifdef _WIN32
auto fd = _fileno(f);
if (_isatty(fd)) {
internal::utf8_to_utf16 u16(string_view(buffer.data(), buffer.size()));
@ -1361,6 +1361,7 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) {
}
#ifdef _WIN32
// Print assuming legacy (non-Unicode) encoding.
FMT_FUNC void vprint_mojibake(std::FILE* f, string_view format_str,
format_args args) {
memory_buffer buffer;