forked from fmtlib/fmt
Enable mojibake
This commit is contained in:
@@ -1507,15 +1507,14 @@ inline std::basic_string<Char> format(const S& format_str, Args&&... args) {
|
|||||||
{internal::make_args_checked<Args...>(format_str, args...)});
|
{internal::make_args_checked<Args...>(format_str, args...)});
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_API void vprint(string_view format_str, format_args args);
|
FMT_API void vprint(string_view, format_args);
|
||||||
FMT_API void vprint(std::FILE* f, string_view format_str, format_args args);
|
FMT_API void vprint(std::FILE*, string_view, format_args);
|
||||||
FMT_API void vprint_mojibake(std::FILE* f, string_view format_str,
|
FMT_API void vprint_mojibake(std::FILE*, string_view, format_args);
|
||||||
format_args args);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
Prints formatted data to the file *f*. For wide format strings,
|
Prints formatted data to the file *f*. For wide format strings *f* should be
|
||||||
*f* should be in wide-oriented mode set via ``fwide(f, 1)``.
|
in wide-oriented mode set via ``fwide(f, 1)``.
|
||||||
|
|
||||||
**Example**::
|
**Example**::
|
||||||
|
|
||||||
@@ -1525,8 +1524,13 @@ FMT_API void vprint_mojibake(std::FILE* f, string_view format_str,
|
|||||||
template <typename S, typename... Args,
|
template <typename S, typename... Args,
|
||||||
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
||||||
inline void print(std::FILE* f, const S& format_str, Args&&... args) {
|
inline void print(std::FILE* f, const S& format_str, Args&&... args) {
|
||||||
|
#if !defined(_WIN32) || FMT_UNICODE
|
||||||
vprint(f, to_string_view(format_str),
|
vprint(f, to_string_view(format_str),
|
||||||
internal::make_args_checked<Args...>(format_str, args...));
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
# include <locale>
|
# include <locale>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FMT_UNICODE
|
#ifdef _WIN32
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -1345,7 +1345,7 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) {
|
|||||||
memory_buffer buffer;
|
memory_buffer buffer;
|
||||||
internal::vformat_to(buffer, format_str,
|
internal::vformat_to(buffer, format_str,
|
||||||
basic_format_args<buffer_context<char>>(args));
|
basic_format_args<buffer_context<char>>(args));
|
||||||
#if defined(_WIN32) && FMT_UNICODE
|
#ifdef _WIN32
|
||||||
auto fd = _fileno(f);
|
auto fd = _fileno(f);
|
||||||
if (_isatty(fd)) {
|
if (_isatty(fd)) {
|
||||||
internal::utf8_to_utf16 u16(string_view(buffer.data(), buffer.size()));
|
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
|
#ifdef _WIN32
|
||||||
|
// Print assuming legacy (non-Unicode) encoding.
|
||||||
FMT_FUNC void vprint_mojibake(std::FILE* f, string_view format_str,
|
FMT_FUNC void vprint_mojibake(std::FILE* f, string_view format_str,
|
||||||
format_args args) {
|
format_args args) {
|
||||||
memory_buffer buffer;
|
memory_buffer buffer;
|
||||||
|
Reference in New Issue
Block a user