Created
March 28, 2017 06:12
-
-
Save zz-jason/42513a6a1b2f636b42777f02b1b535c1 to your computer and use it in GitHub Desktop.
convert a char to its hex representation
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
std::string char_to_hex(unsigned char input) | |
{ | |
static const char* const dict = "0123456789ABCDEF"; | |
std::string result("0x"); | |
result.push_back(dict[input >> 4]); | |
result.push_back(dict[input & 0x0F]); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment