diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-06-23 12:43:39 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-07-05 07:54:28 +1000 |
| commit | 18dfecfa9d112e536829aef72b073f276c32dee1 (patch) | |
| tree | 7930c9b112c9b09d21ffa15ed0bcc96ca4adc9e9 /src/string_utils.hh | |
| parent | 6a31d0ebc796ef216afb27404a0f900216c4ef2a (diff) | |
Introduce a "double_up" function for doubling up escaping
Diffstat (limited to 'src/string_utils.hh')
| -rw-r--r-- | src/string_utils.hh | 4 |
1 files changed, 3 insertions, 1 deletions
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<char> buffer, StringView fmt, Types&&... params) return format_to(buffer, fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...}); } +String double_up(StringView s, StringView characters); + inline String quote(StringView s) { - return format("'{}'", replace(s, "'", "''")); + return format("'{}'", double_up(s, "'")); } } |
