Created
November 18, 2022 16:00
-
-
Save rdhiggins/eb564899fe31a808431e5376521282d1 to your computer and use it in GitHub Desktop.
Takes a collection of binary data and creates a hex string from it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename STD_COLLECTION> | |
std::string as_hex_string(STD_COLLECTION&& collection) { | |
std::stringstream ss; | |
for (unsigned char c: std::forward<STD_COLLECTION>(collection)) | |
ss << std::setfill('0') << std::setw(2) << std::hex << static_cast<short>(c) << " "; | |
return ss.str(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment