File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ Template for new versions:
5959## New Features
6060
6161## Fixes
62+ # ``Filesystem::as_string`` now always uses UTF-8 encoding rather than using the system locale encoding
6263
6364## Misc Improvements
6465
Original file line number Diff line number Diff line change @@ -77,12 +77,13 @@ namespace DFHack {
7777 DFHACK_EXPORT std::filesystem::path canonicalize (std::filesystem::path p) noexcept ;
7878 inline std::string as_string (const std::filesystem::path path) noexcept
7979 {
80- auto pStr = path.string ();
81- if constexpr (std::filesystem::path::preferred_separator != ' /' )
82- {
83- std::ranges::replace (pStr, std::filesystem::path::preferred_separator, ' /' );
84- }
85- return pStr;
80+ // this just mashes the utf-8 into a std::string without any conversion
81+ // this is largely because we use utf-8 everywhere internally as much as we can
82+ // but we should ultimately convert to using u8strings for strings that are utf-8
83+ // and use a different string type for strings encoded in cp437 or in the locale codepage
84+ std::u8string pstr = path.generic_u8string ();
85+ return std::string ((char *)pstr.c_str ());
86+
8687 }
8788 DFHACK_EXPORT std::filesystem::path getInstallDir () noexcept ;
8889 DFHACK_EXPORT std::filesystem::path getBaseDir () noexcept ;
You can’t perform that action at this time.
0 commit comments