mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
to_hex for char*
This commit is contained in:
@@ -97,3 +97,16 @@ std::string zsutil::to_hex(const std::string& input) {
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string zsutil::to_hex(const char* input,size_t length) {
|
||||
std::string output;
|
||||
std::string hex = "0123456789ABCDEF";
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
output += hex[(input[i] & 0xF0) >> 4];
|
||||
output += hex[input[i] & 0x0F];
|
||||
output += " ";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ uint64_t ntohll(uint64_t src);
|
||||
std::string lookup_ws_close_status_string(uint16_t code);
|
||||
|
||||
std::string to_hex(const std::string& input);
|
||||
std::string to_hex(const char* input,size_t length);
|
||||
|
||||
} // namespace zsutil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user