28 #ifndef __TERRALIB_CORE_UTILS_HEXUTILS_H
29 #define __TERRALIB_CORE_UTILS_HEXUTILS_H
250 static char ct[]={
"0123456789ABCDEF" };
275 if(c >=
'0' && c <=
'9')
282 if((c >=
'0') && (c <=
'9'))
452 return ((h << 4) + l);
471 std::size_t hSize = strlen(hex);
473 std::size_t size = hSize / 2;
475 char* buf =
new char[size];
479 for(std::size_t i = 0; i < size; ++i)
483 if(c >=
'0' && c <=
'9')
490 if((c >=
'0') && (c <=
'9'))
495 buf[i] = (h << 4) + l;
515 inline void Hex2Binary(
const char* hex, std::size_t hSize,
char* outBuff)
517 std::size_t size = hSize / 2;
521 for(std::size_t i = 0; i < size; ++i)
525 if(c >=
'0' && c <=
'9')
532 if((c >=
'0') && (c <=
'9'))
537 outBuff[i] = (h << 4) + l;
559 std::size_t hSize = strlen(hex);
561 std::size_t size = hSize / 2;
563 char* buf =
new char[size];
565 for(std::size_t i = 0; i < size; ++i)
583 inline void Hex2Binary2(
const char* hex, std::size_t hSize,
char* outBuff)
585 std::size_t size = hSize / 2;
587 for(std::size_t i = 0; i < size; ++i)
604 char* buff =
new char[2 * size + 1];
623 inline void Binary2Hex(
const char* s, std::size_t size,
char* outBuff)
630 outBuff[i * 2] =
'\0';
char * Binary2Hex(const char *s, std::size_t size)
Each char from the array of characters in binary format is converted into a pair of hex characters....
char * Hex2Binary2(const char *hex)
It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary...
unsigned char GetDecimalFromHexLCase(char hexValue)
It returns the decimal value in a char from a given hex value (for example: 'a' => 10,...
unsigned char Hex2Char2(const char *hex)
It converts the character from a hex representation to a byte.
unsigned char GetDecimalFromHexNotCS(unsigned char hexValue)
It returns the decimal value in a char from a given hex value (for example: 'A' => 10,...
char * Hex2Binary(const char *hex)
It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary...
char Hex2Char(const char *hex)
It converts the character from a hex representation to a byte.
void Char2Hex(unsigned char c, char *r)
It converts the character to a hex representation.
unsigned char GetDecimalFromHexUCase(char hexValue)
It returns the decimal value in a char from a given hex value (for example: 'A' => 10,...