fmtlib / fmtlib/fmt

failed to print error code `:s` fail on windows due to encoding error

Open
#4,436 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
25.8k
Forks
3.1k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

```cxx
#include
#include
#include

#include "fmt/ostream.h"
#include "fmt/std.h"

namespace fs = std::filesystem;

int main() {
const fs::path from{"/none1/a"}, to{"/none2/b"};

try {
fs::copy_file(from, to);
} catch (fs::filesystem_error const &ex) {
std::cout << "what(): " << ex.what() << '\n'
<< "path1(): " << ex.path1() << '\n'
<< "path2(): " << ex.path2() << '\n'
<< "code().value(): " << ex.code().value() << '\n'
<< "code().message(): " << ex.code().message() << '\n'
<< "code().category(): " << ex.code().category().name() << '\n';

try {
fmt::println("{:s}", ex.code());
} catch (std::exception &e) {
fmt::println("fmt error: {}", e.what());
}
}

fmt::println("exit");
return 0;
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.