From 7c60447a3982ac820ee0233e72ff6d52e2c62fb9 Mon Sep 17 00:00:00 2001 From: FRex Date: Tue, 28 Jan 2025 17:59:03 +0100 Subject: [PATCH] Always print filepaths as UTF-8 to a char stream #3406 --- src/SFML/System/Utils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SFML/System/Utils.cpp b/src/SFML/System/Utils.cpp index 7150106f6..53acf060f 100644 --- a/src/SFML/System/Utils.cpp +++ b/src/SFML/System/Utils.cpp @@ -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(path.u8string().c_str()) << '\n' // + << " Absolute path: " << reinterpret_cast(std::filesystem::absolute(path).u8string().c_str()); return oss.str(); }