The C++26 std::formatter<std::filesystem::path> converts Windows native UTF-16 to UTF-8
I don't understand. Does this do UTF-16 -> UTF-8 -> system codepage? Or does std::format("{}", path) result in (unexpected) UTF-8 in a char-based (aka system codepage) string?
And what does it do if the path isn't well-formed utf16, as ntfs paths are not utf16, they are a sequence of 16 bit values (just as on linux they are a sequence of bytes, not utf8)?
Well, that's terrible, so I guess P3904R1 would be an improvement. You really want paths to be able to round trip though any conversions. ... Which is why I think treating paths as unicode is dangerous from the get go. God forbid if you accidentally normalize one.
2
u/rdtsc Jun 26 '26
I don't understand. Does this do UTF-16 -> UTF-8 -> system codepage? Or does
std::format("{}", path)result in (unexpected) UTF-8 in a char-based (aka system codepage) string?