23 #include <drizzled/util/convert.h>
32 uint64_t drizzled_string_to_hex(
char *to,
const char *from, uint64_t from_size)
34 static const char* hex_map=
"0123456789ABCDEF";
36 for (
const char *from_end= from + from_size; from != from_end; from++)
38 *to++= hex_map[((
unsigned char) *from) >> 4];
39 *to++= hex_map[((
unsigned char) *from) & 0xF];
47 static inline char hex_char_value(
char c)
49 if (c >=
'0' && c <=
'9')
51 else if (c >=
'A' && c <=
'F')
53 else if (c >=
'a' && c <=
'f')
58 void drizzled_hex_to_string(
char *to,
const char *from, uint64_t from_size)
60 const char *from_end = from + from_size;
61 while (from != from_end)
63 *to= hex_char_value(*from++) << 4;
65 *to++|= hex_char_value(*from++);
69 void bytesToHexdumpFormat(
string &to,
const unsigned char *from,
size_t from_length)
71 static const char* hex_map=
"0123456789abcdef";
72 ostringstream line_number;
74 for (
size_t x= 0; x < from_length; x+= 16)
76 line_number << setfill(
'0') << setw(6) << x;
77 to.append(line_number.str());
80 for (
size_t y= 0; y < 16; y++)
82 if (x + y < from_length)
84 to.push_back(hex_map[(from[x+y]) >> 4]);
85 to.push_back(hex_map[(from[x+y]) & 0xF]);
92 for (
size_t y= 0; y < 16; y++)
94 if (x + y < from_length)
95 to.push_back(isprint(from[x + y]) ? from[x + y] :
'.');
TODO: Rename this file - func.h is stupid.