Created
March 5, 2014 21:29
-
-
Save denisvm/9377022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void hex2bin(unsigned char *to, const char *p, size_t len) { | |
| register char c1, c2; | |
| for (; *p; to++) { | |
| c1 = *p++; c2 = *p++; | |
| if (!c1 || !isxdigit(c1)) | |
| return; | |
| else if (!c2 || !isxdigit(c2)) | |
| *to = (unsigned char) digittoint(c1); | |
| else | |
| *to = (unsigned char) (digittoint(c1) << 4) | digittoint(c2); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment