Always print filepaths as UTF-8 to a char stream #3406

This commit is contained in:
FRex 2025-01-28 17:59:03 +01:00 committed by Chris Thrasher
parent 4378a022e5
commit 7c60447a39

View File

@ -44,8 +44,10 @@ std::string toLower(std::string str)
std::string formatDebugPathInfo(const std::filesystem::path& path)
{
std::ostringstream oss;
oss << " Provided path: " << path << '\n' //
<< " Absolute path: " << std::filesystem::absolute(path);
// convert to UTF-8 to handle non-ascii/non-latin1 filenames on windows
// cast is required to work in C++20 where u8string is char8_t which can't be printed to char stream
oss << " Provided path: " << reinterpret_cast<const char*>(path.u8string().c_str()) << '\n' //
<< " Absolute path: " << reinterpret_cast<const char*>(std::filesystem::absolute(path).u8string().c_str());
return oss.str();
}