2 ms·
The unfortunate story of Windows is that it tried to do UTF before UTF8 was invented. Java has the same issue. UTF16 existed before UTF8 and now UTF8 has become
by jeroenhd 5y ago
The unfortunate story of Windows is that it tried to do UTF before UTF8 was invented. Java has the same issue. UTF16 existed before UTF8 and now UTF8 has become the norm. That's why you have to deal with wchar_t and other such nonsense in low level languages.
As for C++, the standard library has create_directory (https://en.cppreference.com/w/cpp/filesystem/create_directory https://en.cppreference.com/w/cpp/filesystem/create_director...) in the std::filesystem namespace, taking a std::filesystem::path.
C++17 may not be as widespread as its older companions, but if you're using the language in a modern context there's a perfectly usable set of standard APIs for this stuff that works with a whole bunch of char types (or the std::u8string if you're on modern C++ and want to forego the whole UTF issue as much as possible).
The problem is that you have to deal with edge cases. File system corruption happens and iterating over JSON files in a directory can show random character sequences at any point in time. You can choose to ignore it, or fail on error, or let the language decide what to do in the case of Go, but you always need to be mindful of the failures that can happen. Ignoring the problem won't make it go away and eventually it'll bite you in the ass of you keep doing it.
- OvermindDL1 5y agoRust may give a subset of file system functionality that all general file systems should in theory support in the front interface, but you can access platform specific functionality by asking for the extended interface, which you put inside a platform check block. You have the full functionality there.
- account42 5y ago> The unfortunate story of Windows is that it tried to do UTF before UTF8 was invented. Java has the same issue. UTF16 existed before UTF8 and now UTF8 has become the norm. That's why you have to deal with wchar_t and other such nonsense in low level languages. UTF-8 was first implemented in 1992 while UTF-16 was specified in 1996. Windows and Java use UTF-8 because they retconned their UCS-2 APIs to expect UTF-16 rather than add UTF-8 support. For Windows this is especially damning as they already had a API for encodings with 8-bit code units which they didn't bother adding UTF-8 support to until very recently.