diff options
Diffstat (limited to 'src/util/hex.h')
-rw-r--r-- | src/util/hex.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/util/hex.h b/src/util/hex.h index 6f00a79bf..c205d01da 100644 --- a/src/util/hex.h +++ b/src/util/hex.h @@ -30,9 +30,8 @@ static inline std::string hex_encode(const char *data, unsigned int data_size) char buf2[3]; buf2[2] = '\0'; - for(unsigned int i = 0; i < data_size; i++) - { - unsigned char c = (unsigned char) data[i]; + for (unsigned int i = 0; i < data_size; i++) { + unsigned char c = (unsigned char)data[i]; buf2[0] = hex_chars[(c & 0xf0) >> 4]; buf2[1] = hex_chars[c & 0x0f]; ret.append(buf2); @@ -43,16 +42,16 @@ static inline std::string hex_encode(const char *data, unsigned int data_size) static inline std::string hex_encode(const std::string &data) { - return hex_encode(data.c_str(), data.size()); + return hex_encode(data.c_str(), data.size()); } static inline bool hex_digit_decode(char hexdigit, unsigned char &value) { - if(hexdigit >= '0' && hexdigit <= '9') + if (hexdigit >= '0' && hexdigit <= '9') value = hexdigit - '0'; - else if(hexdigit >= 'A' && hexdigit <= 'F') + else if (hexdigit >= 'A' && hexdigit <= 'F') value = hexdigit - 'A' + 10; - else if(hexdigit >= 'a' && hexdigit <= 'f') + else if (hexdigit >= 'a' && hexdigit <= 'f') value = hexdigit - 'a' + 10; else return false; |