adds to_hex debug utility function

This commit is contained in:
Peter Thorson
2012-01-08 20:18:24 -06:00
parent 12bc3432f4
commit 548ea142ff
2 changed files with 15 additions and 0 deletions

View File

@@ -79,4 +79,17 @@ std::string lookup_ws_close_status_string(uint16_t code) {
default:
return "Unknown";
}
}
std::string to_hex(const std::string& input) {
std::string output;
std::string hex = "0123456789ABCDEF";
for (size_t i = 0; i < input.size(); i++) {
output += hex[(input[i] & 0xF0) >> 4];
output += hex[input[i] & 0x0F];
output += " ";
}
return output;
}

View File

@@ -44,4 +44,6 @@ uint64_t ntohll(uint64_t src);
std::string lookup_ws_close_status_string(uint16_t code);
std::string to_hex(const std::string& input);
#endif // NETWORK_UTILITIES_HPP