What encoding does Linux use for its file APIs? How should I work with path strings in C++, what class to use? I mean paths with non-ASCII characters. On Windows I use UTF-16 and std::wstring, on Mac - UTF-8 and my own UTF-8 string class. But unfortunately my class is not available on Linux, so what should I use?
Internally, Linux permits to use any byte sequence for file name, except for null byte 0 and forward slash '/' (which is used as directory separator).
Common convention to permit Unicode file names on Linux is to use UTF-8 encoding for file names. Easiest way to achieve that is to use good old std::string (not std::wstring which is suggested on Windows), however, you may need to write your own class which will validate that it is indeed valid UTF-8.
There are few examples of ready-to-use libraries that provide handling of UTF-8 strings:
std::string, GPL).Linux does not enforce an encoding on file names. Using UTF-8 is common though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With