I ask this because I am using SFML strings. sf::String does not insert a new line in the presence of a \n.
I can't seem to figure out a way without using 3/4 STL algorithms.
std::replace_if(str.begin(), str.end(), [](const char&c](return c == '\\n'), '\n'});
does not work. The string remains the same.
I have also tried replacing the \\ occurrence with a temporary, say ~. This works, but when I go to replace the ~ with \, then it adds a \\ instead of a \
I have produced a solution by manually replacing and deleting duplicates after \n insertion :
for (auto it = str.begin(); it != str.end(); ++it) {
if (*it == '\\') {
if (it + 1 != str.end()) {
if (*(it + 1) != 'n') continue;
*it = '\n';
str.erase(it + 1);
}
}
}