diff options
Diffstat (limited to 'src/utils.cpp')
-rw-r--r-- | src/utils.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils.cpp b/src/utils.cpp index 014d0da1..683cc396 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -450,6 +450,22 @@ std::string utils::replace_all(const std::string& str, return output; } +std::string utils::preserve_quotes(const std::string& str) +{ + std::string escaped_string = ""; + std::vector<std::string> string_tokenized = tokenize_spaced(str, "'"); + for (std::string string_chunk : string_tokenized) { + if (string_chunk[0] == '\'') { + for (size_t i = 0; i < string_chunk.length(); i++) { + escaped_string += "\\\'"; + } + } else { + escaped_string += "'" + string_chunk + "'"; + } + } + return escaped_string; +} + std::wstring utils::str2wstr(const std::string& str) { const char* codeset = nl_langinfo(CODESET); |