One small problem arose, when I do like this, then everything is fine:

std::cout << std::filesystem::current_path().parent_path().append("Resources").append("Shaders").string().c_str() << std::endl; 

In this case, the correct path is displayed, but as soon as I do this:

 std::filesystem::path path = std::filesystem::current_path().parent_path().append("Resources").append("Shaders"); const char* shadersPath = path.string().c_str(); // ΠΈΠ»ΠΈ u8string().c_str() std::cout << shadersPath << std::endl; 

As a result, I get a problem with the encoding:

β–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œ β–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œβ–Œ K

What could be the problem? I need to get exactly C string in ANSI or UTF-8

  • one
    And what is the system? And what is the path.string() ? - VTT
  • Windows 10 Returns the path in string format, from the documentation picked up. en.cppreference.com/w/cpp/filesystem/path - QuickDzen
  • one
    If this is Windows, then to translate to utf8 you will need to convert the path from wchar_t using the ICU library or the MultibyteToWideChar function. Then to print convert the path back to wchar_t - VTT

0