A lot of updates
This commit is contained in:
@@ -15,6 +15,19 @@ namespace hex {
|
||||
output[idx++] = static_cast<char>(beg + ((elm & 0x0F) >> 0));
|
||||
}
|
||||
|
||||
return std::string(output, len);
|
||||
}
|
||||
inline std::string hex(const std::string& input){
|
||||
size_t len = input.length() * 2;
|
||||
char output[len];
|
||||
size_t idx = 0;
|
||||
for (char elm : input) {
|
||||
auto lower = ((uint8_t) elm >> 4U) & 0xFU;
|
||||
auto upper = ((uint8_t) elm & 0xFU) >> 0U;
|
||||
output[idx++] = static_cast<char>(lower > 9 ? 'a' + (lower - 9) : '0' + lower);
|
||||
output[idx++] = static_cast<char>(upper > 9 ? 'a' + (upper - 9) : '0' + upper);
|
||||
}
|
||||
|
||||
return std::string(output, len);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user