MCPcopy Create free account
hub / github.com/defold/defold / decode_hex4

Function decode_hex4

engine/script/src/luacjson/lua_cjson.c:1033–1052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031}
1032
1033static int decode_hex4(const char *hex)
1034{
1035 int digit[4];
1036 int i;
1037
1038 /* Convert ASCII hex digit to numeric digit
1039 * Note: this returns an error for invalid hex digits, including
1040 * NULL */
1041 for (i = 0; i < 4; i++) {
1042 digit[i] = hexdigit2int(hex[i]);
1043 if (digit[i] < 0) {
1044 return -1;
1045 }
1046 }
1047
1048 return (digit[0] << 12) +
1049 (digit[1] << 8) +
1050 (digit[2] << 4) +
1051 digit[3];
1052}
1053
1054/* Converts a Unicode codepoint to UTF-8.
1055 * 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