In C++17 we will have file system support. This example from cppreference is supposed to work correctly:
fs::path p = fs::u8path(u8"要らない.txt");
// native string representation can be used with OS APIs
std::ofstream(p) << "File contents"; // this uses operator string()
However, I don't see how it will work on Windows, since std::filesystem::path::operator string_type()
will return std::wstring
on Windows, and std::basic_ofstream
constructor accepts only std::string
. Is this right? I hope not, thus where is my mistake?