#include using namespace std; std::string unfuck_windows_path(std::string path); int main() { auto in = "C:\\Users\\Мистер Йож\\Мои Документы\\Мои Игры"; auto out = unfuck_windows_path(in); std::cout << out << std::endl; return 0; } std::string unfuck_windows_path(std::string path) { const int backSlashChar = '\\'; int firstChar = path.find(backSlashChar); std::string result = path.substr(0, firstChar); result.reserve(path.size()); for (size_t i = firstChar, end = path.size(); i < end; ++i) { switch (auto symbol = path[i]) { case 'a' ... 'z': [[fallthrough]]; case 'A' ... 'Z': [[fallthrough]]; case '0' ... '9': [[fallthrough]]; case '-': [[fallthrough]]; case '_': [[fallthrough]]; case '/': [[fallthrough]]; case '.': result.push_back(symbol); break; case backSlashChar: result.push_back('/'); break; default: result.push_back('_'); break; } } return result; }