From 2f48bbf6ff0c2bad4d06ce1189cd8e0e50d7a447 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 7 Dec 2017 01:56:02 +0800 Subject: Tweak unescape template function to unescape the escape char as well Test that more thouroughly in the unit tests. --- src/string_utils.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/string_utils.hh') 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 -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 = " "); -- cgit v1.2.3