A pure C function that will do the hex-2-int conversion.
This function takes the whole hexadecimal string.
You need:
- http://objective-c-functions.blogspot.com/2013/07/hex-to-int-conversion-single-char.html
/** Convert a hex number to an int.
@param p Characters of the hexadecimal value.
@return Returns the integer value.
*/
int hex2(char *p) {
int i;
unsigned char c;
i = hex(*p++);
if (i < 0) return i;
c = (i << 4);
i = hex(*p);
if (i < 0) return i;
return c | i;
}
Download the ready-for-use source file (.m) of Hex to int conversion (full string)
No comments:
Post a Comment