mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-02 07:09:44 +01:00
unicode_to_utf8 -> to_utf8 since both sides of conversion are Unicode
This commit is contained in:
17
src/os.cc
17
src/os.cc
@@ -110,9 +110,9 @@ class utf8_system_category final : public std::error_category {
|
||||
public:
|
||||
const char* name() const noexcept override { return "system"; }
|
||||
std::string message(int error_code) const override {
|
||||
system_message msg(error_code);
|
||||
auto&& msg = system_message(error_code);
|
||||
if (msg) {
|
||||
unicode_to_utf8<wchar_t> utf8_message;
|
||||
auto utf8_message = to_utf8<wchar_t>();
|
||||
if (utf8_message.convert(msg)) {
|
||||
return utf8_message.str();
|
||||
}
|
||||
@@ -137,12 +137,12 @@ std::system_error vwindows_error(int err_code, string_view format_str,
|
||||
void detail::format_windows_error(detail::buffer<char>& out, int error_code,
|
||||
const char* message) noexcept {
|
||||
FMT_TRY {
|
||||
system_message msg(error_code);
|
||||
auto&& msg = system_message(error_code);
|
||||
if (msg) {
|
||||
unicode_to_utf8<wchar_t> utf8_message;
|
||||
auto utf8_message = to_utf8<wchar_t>();
|
||||
if (utf8_message.convert(msg)) {
|
||||
fmt::format_to(buffer_appender<char>(out), FMT_STRING("{}: {}"),
|
||||
message, string_view(utf8_message));
|
||||
fmt::format_to(appender(out), FMT_STRING("{}: {}"), message,
|
||||
string_view(utf8_message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -337,9 +337,8 @@ file file::open_windows_file(wcstring_view path, int oflag) {
|
||||
int fd = -1;
|
||||
auto err = _wsopen_s(&fd, path.c_str(), oflag, _SH_DENYNO, default_open_mode);
|
||||
if (fd == -1) {
|
||||
FMT_THROW(
|
||||
system_error(err, FMT_STRING("cannot open file {}"),
|
||||
detail::unicode_to_utf8<wchar_t>(path.c_str()).c_str()));
|
||||
FMT_THROW(system_error(err, FMT_STRING("cannot open file {}"),
|
||||
detail::to_utf8<wchar_t>(path.c_str()).c_str()));
|
||||
}
|
||||
return file(fd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user