From 4c392178dac1de9a299beb78989c4e0f3fecade9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 20 May 2018 11:15:15 +0200 Subject: Add image preview and url/image open in browser --- include/StringUtils.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/StringUtils.hpp (limited to 'include/StringUtils.hpp') diff --git a/include/StringUtils.hpp b/include/StringUtils.hpp new file mode 100644 index 0000000..6b237dd --- /dev/null +++ b/include/StringUtils.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace dchat +{ + static std::string stringReplaceChar(const std::string &str, const std::string &from, const std::string &to) + { + std::string result = str; + size_t pos = 0; + while((pos = result.find(from, pos)) != std::string::npos) + { + result.replace(pos, from.size(), to); + pos += to.size(); + } + return result; + } +} -- cgit v1.2.3