MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxUint8ArrayFromHex

Function fxUint8ArrayFromHex

xs/sources/xsDataView.c:3541–3564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3539}
3540
3541static void fxUint8ArrayFromHex(txMachine* the, txU1* srcStart, txU1* dstStart, txSize* read, txSize* written)
3542{
3543#define mxFromHex(X) \
3544 if (('0' <= X) && (X <= '9')) X = X - '0'; \
3545 else if (('A' <= X) && (X <= 'F')) X = X - 'A' + 10; \
3546 else if (('a' <= X) && (X <= 'f')) X = X - 'a' + 10; \
3547 else mxSyntaxError("invalid string")
3548
3549 txU1* src = srcStart;
3550 txU1* dst = dstStart;
3551 txSize srcSize = *read;
3552 txSize dstSize = *written;
3553 while ((srcSize > 0) && (dstSize > 0)) {
3554 txU1 high = c_read8(src++);
3555 txU1 low = c_read8(src++);
3556 mxFromHex(high);
3557 mxFromHex(low);
3558 *dst++ = (high << 4) + low;
3559 srcSize -= 2;
3560 dstSize--;
3561 }
3562 *read = (txSize)(src - srcStart);
3563 *written = (txSize)(dst - dstStart);
3564}
3565
3566static void fxUint8ArrayGetBase64Options(txMachine* the, txInteger argi, txU1** alphabet, txInteger* lastChunkHandling, txBoolean* omitPadding)
3567{

Callers 2

fx_Uint8Array_fromHexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected