summaryrefslogtreecommitdiff
path: root/src/string_utils.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-12-07 01:56:02 +0800
committerMaxime Coste <mawww@kakoune.org>2017-12-07 01:56:02 +0800
commit2f48bbf6ff0c2bad4d06ce1189cd8e0e50d7a447 (patch)
treea4c40a6db41aaa483f947135023e981a9d43089c /src/string_utils.hh
parent99636c6230f9a3f6a818db5a301137114bf79617 (diff)
Tweak unescape template function to unescape the escape char as well
Test that more thouroughly in the unit tests.
Diffstat (limited to 'src/string_utils.hh')
-rw-r--r--src/string_utils.hh6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/string_utils.hh b/src/string_utils.hh
index f1796f7c..e8442fc2 100644
--- a/src/string_utils.hh
+++ b/src/string_utils.hh
@@ -14,7 +14,11 @@ String escape(StringView str, StringView characters, char escape);
String unescape(StringView str, StringView characters, char escape);
template<char character, char escape>
-String unescape(StringView str) { return unescape(str, character, escape); }
+String unescape(StringView str)
+{
+ const char to_escape[2] = { character, escape };
+ return unescape(str, {to_escape, 2}, escape);
+}
String indent(StringView str, StringView indent = " ");