MCPcopy Create free account
hub / github.com/axmolengine/axmol / decode_hex4

Function decode_hex4

3rdparty/lua/lua-cjson/lua_cjson.c:780–799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778}
779
780static int decode_hex4(const char *hex)
781{
782 int digit[4];
783 int i;
784
785 /* Convert ASCII hex digit to numeric digit
786 * Note: this returns an error for invalid hex digits, including
787 * NULL */
788 for (i = 0; i < 4; i++) {
789 digit[i] = hexdigit2int(hex[i]);
790 if (digit[i] < 0) {
791 return -1;
792 }
793 }
794
795 return (digit[0] << 12) +
796 (digit[1] << 8) +
797 (digit[2] << 4) +
798 digit[3];
799}
800
801/* Converts a Unicode codepoint to UTF-8.
802 * 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