summaryrefslogtreecommitdiff
path: root/zen/string_tools.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-04-18 12:59:51 -0400
committerB Stack <bgstack15@gmail.com>2020-04-18 12:59:51 -0400
commitfc8cd27e4c0c8a48ebc151f73639a573e9e5c7f0 (patch)
tree8cfcea5441be72ad92095a3887ded84d38f9ba11 /zen/string_tools.h
parentMerge branch '10.22' into 'master' (diff)
downloadFreeFileSync-fc8cd27e4c0c8a48ebc151f73639a573e9e5c7f0.tar.gz
FreeFileSync-fc8cd27e4c0c8a48ebc151f73639a573e9e5c7f0.tar.bz2
FreeFileSync-fc8cd27e4c0c8a48ebc151f73639a573e9e5c7f0.zip
add upstream 10.23
Diffstat (limited to 'zen/string_tools.h')
-rw-r--r--zen/string_tools.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/zen/string_tools.h b/zen/string_tools.h
index 40a4ea52..cd26f5fd 100644
--- a/zen/string_tools.h
+++ b/zen/string_tools.h
@@ -83,6 +83,7 @@ template <class Num, class S> Num stringTo(const S& str);
std::pair<char, char> hexify (unsigned char c, bool upperCase = true);
char unhexify(char high, char low);
+std::string formatAsHexString(const std::string& blob); //bytes -> (human-readable) hex string
template <class S, class T, class Num> S printNumber(const T& format, const Num& number); //format a single number using std::snprintf()
@@ -848,6 +849,20 @@ char unhexify(char high, char low)
}
+inline
+std::string formatAsHexString(const std::string& blob)
+{
+ std::string output;
+ for (const char c : blob)
+ {
+ const auto [high, low] = hexify(c, false /*upperCase*/);
+ output += high;
+ output += low;
+ }
+ return output;
+}
+
+
}
#endif //STRING_TOOLS_H_213458973046
bgstack15