summaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp
index d027cb7bf..aeac4fe84 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <ctype.h> /* required for tolower() */
#include <sstream>
+#include <iomanip>
#ifdef _MSC_VER
#include <errno.h> // required by vsnprintf implementation for MSVC
@@ -161,6 +162,23 @@ char *CDECL str_fmt(const char *str, ...)
}
/**
+ * Format a byte array into a continuous hex string.
+ * @param data Array to format
+ * @return Converted string.
+ */
+std::string FormatArrayAsHex(span<const byte> data)
+{
+ std::ostringstream ss;
+ ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex;
+
+ for (auto b : data) {
+ ss << b;
+ }
+
+ return ss.str();
+}
+
+/**
* Scan the string for old values of SCC_ENCODED and fix it to
* it's new, static value.
* @param str the string to scan