MCPcopy Create free account
hub / github.com/ElementsProject/elements / hatoui

Function hatoui

src/univalue/lib/univalue_read.cpp:25–49  ·  view source on GitHub ↗

convert hexadecimal string to unsigned integer

Source from the content-addressed store, hash-verified

23
24// convert hexadecimal string to unsigned integer
25static const char *hatoui(const char *first, const char *last,
26 unsigned int& out)
27{
28 unsigned int result = 0;
29 for (; first != last; ++first)
30 {
31 int digit;
32 if (json_isdigit(*first))
33 digit = *first - '0';
34
35 else if (*first >= 'a' && *first <= 'f')
36 digit = *first - 'a' + 10;
37
38 else if (*first >= 'A' && *first <= 'F')
39 digit = *first - 'A' + 10;
40
41 else
42 break;
43
44 result = 16 * result + digit;
45 }
46 out = result;
47
48 return first;
49}
50
51enum jtokentype getJsonToken(std::string& tokenVal, unsigned int& consumed,
52 const char *raw, const char *end)

Callers 1

getJsonTokenFunction · 0.85

Calls 1

json_isdigitFunction · 0.85

Tested by

no test coverage detected