Hex conversion routines.
More...
Go to the source code of this file.
|
| size_t | mlib::hexbin (unsigned char *dst, const char *src, size_t sz) |
| | convert a string of hex digits to binary
|
| |
| void | mlib::binhex (char *dst, const unsigned char *src, size_t sz) |
| | convert binary data to a string of hex digits
|
| |
| void | mlib::bytehex (char *dst, unsigned char bin) |
| | convert one byte to two hex digits
|
| |
| void | mlib::shorthex (char *dst, unsigned short bin) |
| | convert a short integer to 4 hex digits
|
| |
| void | mlib::longhex (char *dst, unsigned long bin) |
| | convert a long integer to 8 hex digits
|
| |
| bool | mlib::hexbyte (unsigned char &dst, const char *src) |
| | convert two ASCII hex digits to binary
|
| |
| bool | mlib::hexshort (unsigned short &dst, const char *src) |
| | convert four ASCII hex digits to binary
|
| |
| bool | mlib::hexlong (unsigned long &dst, const char *src) |
| | convert eight ASCII hex digits to binary
|
| |
◆ binhex()
| void mlib::binhex |
( |
char * | str, |
|
|
const unsigned char * | bin, |
|
|
size_t | sz ) |
convert binary data to a string of hex digits
- Parameters
-
| str | output string |
| bin | input binary data |
| sz | size of binary data |
The output string is null-terminated. It must be at least 2*sz+1 bytes.
◆ bytehex()
| void mlib::bytehex |
( |
char * | str, |
|
|
unsigned char | bin ) |
convert one byte to two hex digits
- Parameters
-
| str | output string. Must be at least 3 bytes long |
| bin | input binary value |
The output string is null-terminated.
◆ hexbin()
| size_t mlib::hexbin |
( |
unsigned char * | bin, |
|
|
const char * | str, |
|
|
size_t | sz ) |
convert a string of hex digits to binary
- Parameters
-
| bin | resulting binary data |
| str | input hex string |
| sz | maximum size of binary data |
- Returns
- number of bytes converted
◆ hexbyte()
| bool mlib::hexbyte |
( |
unsigned char & | bin, |
|
|
const char * | str ) |
convert two ASCII hex digits to binary
- Parameters
-
| bin | resulting byte value |
| str | input string of hex digits |
- Returns
true if conversion was successful, false otherwise
◆ hexlong()
| bool mlib::hexlong |
( |
unsigned long & | bin, |
|
|
const char * | str ) |
convert eight ASCII hex digits to binary
- Parameters
-
| bin | resulting long integer value |
| str | input string of hex digits |
- Returns
true if conversion was successful, false otherwise
◆ hexshort()
| bool mlib::hexshort |
( |
unsigned short & | bin, |
|
|
const char * | str ) |
convert four ASCII hex digits to binary
- Parameters
-
| bin | resulting short integer value |
| str | input string of hex digits |
- Returns
true if conversion was successful, false otherwise
◆ longhex()
| void mlib::longhex |
( |
char * | str, |
|
|
unsigned long | bin ) |
convert a long integer to 8 hex digits
- Parameters
-
| str | output string. Must be at least 9 bytes long |
| bin | input binary value |
The output string is null-terminated.
◆ shorthex()
| void mlib::shorthex |
( |
char * | str, |
|
|
unsigned short | bin ) |
convert a short integer to 4 hex digits
- Parameters
-
| str | output string. Must be at least 5 bytes long |
| bin | input binary value |
The output string is null-terminated.