MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / decode_hex4

Function decode_hex4

deps/lua/src/lua_cjson.c:752–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750}
751
752static int decode_hex4(const char *hex)
753{
754 int digit[4];
755 int i;
756
757 /* Convert ASCII hex digit to numeric digit
758 * Note: this returns an error for invalid hex digits, including
759 * NULL */
760 for (i = 0; i < 4; i++) {
761 digit[i] = hexdigit2int(hex[i]);
762 if (digit[i] < 0) {
763 return -1;
764 }
765 }
766
767 return (digit[0] << 12) +
768 (digit[1] << 8) +
769 (digit[2] << 4) +
770 digit[3];
771}
772
773/* Converts a Unicode codepoint to UTF-8.
774 * Returns UTF-8 string length, and up to 4 bytes in *utf8 */

Callers 1

Calls 1

hexdigit2intFunction · 0.85

Tested by

no test coverage detected