move reverse_string to string.hpp

This commit is contained in:
Twan van Laarhoven
2020-04-14 20:27:39 +02:00
parent 36918281c0
commit 0cffdb7d1a
3 changed files with 12 additions and 8 deletions
+9
View File
@@ -79,6 +79,15 @@ String replace_all(const String& heystack, const String& needle, const String& r
return ret;
}
String reverse_string(String const& input) {
// Note: std::reverse doesn't work because of unicode encoding stuff
String reversed;
for (auto it = input.rbegin(); it != input.rend(); ++it) {
reversed += *it;
}
return reversed;
}
// ----------------------------------------------------------------------------- : Words
String last_word(const String& s) {