MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / decode_hex4

Function decode_hex4

LuaSTGPlus/LuaExtensions/cjson4lua/lua_cjson.c:755–774  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753}
754
755static int decode_hex4(const char *hex)
756{
757 int digit[4];
758 int i;
759
760 /* Convert ASCII hex digit to numeric digit
761 * Note: this returns an error for invalid hex digits, including
762 * NULL */
763 for (i = 0; i < 4; i++) {
764 digit[i] = hexdigit2int(hex[i]);
765 if (digit[i] < 0) {
766 return -1;
767 }
768 }
769
770 return (digit[0] << 12) +
771 (digit[1] << 8) +
772 (digit[2] << 4) +
773 digit[3];
774}
775
776/* Converts a Unicode codepoint to UTF-8.
777 * 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