MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / hexDecode

Function hexDecode

source/core/StarEncode.cpp:17–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17size_t hexDecode(char const* src, size_t len, char* output, size_t outLen) {
18 for (size_t i = 0; i < len / 2; ++i) {
19 if (i >= outLen)
20 return i;
21
22 uint8_t b1 = 0;
23 char c1 = src[i * 2];
24 if (c1 >= '0' && c1 <= '9')
25 b1 = c1 - '0';
26 else if (c1 >= 'A' && c1 <= 'F')
27 b1 = c1 - 'A' + 10;
28 else if (c1 >= 'a' && c1 <= 'f')
29 b1 = c1 - 'a' + 10;
30
31 uint8_t b2 = 0;
32 char c2 = src[i * 2 + 1];
33 if (c2 >= '0' && c2 <= '9')
34 b2 = c2 - '0';
35 else if (c2 >= 'A' && c2 <= 'F')
36 b2 = c2 - 'A' + 10;
37 else if (c2 >= 'a' && c2 <= 'f')
38 b2 = c2 - 'a' + 10;
39
40 *output++ = (b1 << 4) | b2;
41 }
42
43 return len / 2;
44}
45
46size_t nibbleDecode(char const* src, size_t len, char* output, size_t outLen) {
47 for (size_t i = 0; i < len; ++i) {

Callers 8

UniverseServerMethod · 0.85
hexToVec4BMethod · 0.85
imageOperationFromStringFunction · 0.85
UuidMethod · 0.85
hexStringToUtf32Function · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85

Calls 4

sizeMethod · 0.45
utf8PtrMethod · 0.45
utf8SizeMethod · 0.45
ptrMethod · 0.45

Tested by 3

TESTFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68