aboutsummaryrefslogtreecommitdiff
path: root/include/StringUtils.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-20 11:15:15 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-20 11:15:18 +0200
commit4c392178dac1de9a299beb78989c4e0f3fecade9 (patch)
tree552b7a7dfa58e8193705934059e28461815bb951 /include/StringUtils.hpp
parent34e1d3d9d40f9b9139b801de99292a563c3c9a96 (diff)
Add image preview and url/image open in browser
Diffstat (limited to 'include/StringUtils.hpp')
-rw-r--r--include/StringUtils.hpp18
1 files changed, 18 insertions, 0 deletions
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 <string>
+
+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;
+ }
+}