From 18dfecfa9d112e536829aef72b073f276c32dee1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 23 Jun 2018 12:43:39 +1000 Subject: Introduce a "double_up" function for doubling up escaping --- src/string_utils.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/string_utils.hh') diff --git a/src/string_utils.hh b/src/string_utils.hh index 61a28cad..558ba62f 100644 --- a/src/string_utils.hh +++ b/src/string_utils.hh @@ -128,9 +128,11 @@ StringView format_to(ArrayView buffer, StringView fmt, Types&&... params) return format_to(buffer, fmt, ArrayView{detail::format_param(std::forward(params))...}); } +String double_up(StringView s, StringView characters); + inline String quote(StringView s) { - return format("'{}'", replace(s, "'", "''")); + return format("'{}'", double_up(s, "'")); } } -- cgit v1.2.3