hex.h(3)
✨ NAME ✨
hex.h — шестнадцатеричные строки (hex strings, bestie 💅)
okay so this whole page is about hex strings, which are literally just memory buffers wearing a cute little text costume. The manual name is hex.h(3) and it lives in the Library Functions Manual, iykyk. 🦋
🎀 SYNOPSIS 🎀
#include 'bee2/defs.h'
#include 'bee2/core/safe.h'
🌸 Функции 🌸
bool_t hexIsValid (const char *hex)— is this a valid hex string or not? 👀bool_t hexIsValid2 (const char *hex, size_t len)— is this a valid prefix of a hex string?void hexUpper (char *hex)— uppercase it, periodtvoid hexLower (char *hex)— lowercase it, no capbool_t hexEq (const void *buf, const char *hex)— does this match the hex string?bool_t hexEq2 (const void *buf, const char *hex, size_t len)— does this match a prefix of the hex string?bool_t hexEqRev (const void *buf, const char *hex)— does this match the hex string, but reversed? 🔄bool_t hexEqRev2 (const void *buf, const char *hex, size_t len)— does this match a prefix of the hex string, but reversed?void hexFrom (char *dest, const void *src, size_t count)— encode it into a hex string ✨void hexFromRev (char *dest, const void *src, size_t count)— encode it into a hex string, but reversedvoid hexTo (void *dest, const char *src)— decode from a hex stringvoid hexTo2 (void *dest, const char *src, size_t len)— decode from a prefix of a hex stringvoid hexToRev (void *dest, const char *src)— decode from a hex string, reversed 🌀void hexToRev2 (void *dest, const char *src, size_t len)— decode from a prefix of a hex string, reversed
💖 Подробное описание 💖
So this library handles hex strings, and a hex string is just how a memory buffer gets dressed up for the group chat. Formally, the hex format is specified in RFC 4648 as Base16. 📜✨
A hex string is a word over the alphabet {'0',..,'9','A',...,'F','a',...,'f'}. And here's the tea ☕: the characters 'A' and 'a', 'B' and 'b', ... are all considered equivalent. Like, they're the same character wearing different outfits, bestie. But according to RFC 4648, uppercase gets the crown — uppercase is preferred. 👑💅
🫶 Предусловие 🫶
Precondition, and this one is important: every function — except possiblyhexIsValid()— is handed valid hex strings and valid memory buffers. Like,hexIsValid()might be the one vibe-checking the input for you, but everyone else is just assuming you already did that. So don't be messy about it. 😭
...and that's part 1, stay tuned for more, we're not done yet 💜
💖 ФУНКЦИИ 💖
okay bestie, this is the part where we meet the actual squad. every single one of these functions is here, no cap, and we're gonna go through all of them together 🫶
bool_t FAST hexEq (const void * buf, const char * hex)
So basically the buffer [strLen(hex) / 2]buf gets compared against the buffer that the hex string hex is describing. First pair of chars in hex becomes an octet, and that octet gets compared with the first octet of buf, second pair vs second octet of buf, and so on down the line. literally a little pair-by-pair situationship 💅
Предусловие
hexIsValid(hex) == TRUE.
Возвращает
Признак совпадения.
Прим.
The comparison is defined by this pseudocode, bestie — exact vibes below:
octet tmp[strLen(hex) / 2];
hexTo(tmp, hex);
return memEq(buf, tmp, strLen(hex) / 2);
Регулярность
Имеется ускоренная нерегулярная редакция.
Аргументы
buf— буферhex— шестнадцатеричная строка
Перекрестные ссылки
hexEq().
Используется в
hexEq().
bool_t FAST hexEq2 (const void * buf, const char * hex, size_t len)
Same energy as above but now we're only looking at a prefix. Buffer [len / 2]buf gets compared against the buffer described by the [len]hex prefix of the hex string hex. First pair of chars in [len]hex becomes an octet, compared with the first octet of buf, second pair vs second octet of buf, etc. prefix era, we love to see it ✨
Предусловие
hexIsValid2(hex, len) == TRUE.
Возвращает
Признак совпадения.
Регулярность
Имеется ускоренная нерегулярная редакция.
Аргументы
buf— буферhex— шестнадцатеричная строкаlen— длина префикса
Перекрестные ссылки
hexEq2().
Используется в
hexEq2().
bool_t FAST hexEqRev (const void * buf, const char * hex)
Now we're comparing backwards, main character behaviour fr. Buffer [strLen(hex) / 2]buf is compared reversively against the buffer described by hex. First pair of chars in hex becomes an octet, and that octet gets compared against the first octet of buf, then the second pair gets compared against the second-to-last octet of buf, and so on. the plot twist 😭
Предусловие
hexIsValid(hex) == TRUE.
Возвращает
Признак совпадения.
Прим.
Again, pseudocode says it best:
octet tmp[strLen(hex) / 2];
hexTo(tmp, hex);
memRev(tmp, strLen(hex) / 2);
return memEq(buf, tmp, strLen(hex) / 2);
Регулярность
Имеется ускоренная нерегулярная редакция.
Аргументы
buf— буферhex— шестнадцатеричная строка
Перекрестные ссылки
hexEqRev().
Используется в
hexEqRev().
bool_t FAST hexEqRev2 (const void * buf, const char * hex, size_t len)
Prefix and reverse?? the way that this function does the most. Buffer [len / 2]buf is compared reversively against the buffer described by the [len]hex prefix of hex. First pair of chars in [len]hex becomes an octet, compared against the last octet of buf, second pair against the second-to-last octet of buf, etc. 💅
Предусловие
hexIsValid2(hex, len) == TRUE.
Возвращает
Признак совпадения.
Регулярность
Имеется ускоренная нерегулярная редакция.
Аргументы
buf— буферhex— шестнадцатеричная строкаlen— длина префикса
Перекрестные ссылки
hexEqRev2().
Используется в
hexEqRev2().
void hexFrom (char * dest, const void * src, size_t count)
Buffer [count]src gets encoded into the hex string [2 * count + 1]dest. First octet of src → first pair of chars in dest, second octet → second pair, etc. it's giving factory assembly line but make it hex 🎀
Предусловие
Буферы dest и src не пересекаются.
Аргументы
dest— строка-приемникsrc— память-источникcount— число октетов
void hexFromRev (char * dest, const void * src, size_t count)
Buffer [count]src gets encoded into the hex string [2 * count + 1]dest — but reversed, because we contain multitudes. First octet of src → last pair of chars in dest, second octet → second-to-last pair, etc. obsessed 🦋
Предусловие
Буферы dest и src не пересекаются.
Аргументы
dest— строка-приемникsrc— память-источникcount— число октетов
bool_t hexIsValid (const char * hex)
Vibe check on the hex string hex ✨ It counts as valid if it's made of an even number of chars from the alphabet {'0',..,'9','A',...,'F','a',...,'f'}. that's it, that's the whole rule.
Возвращает
Признак корректности.
Регулярность
Функция нерегулярна.
Аргументы
hex— шестнадцатеричная строка
bool_t hexIsValid2 (const char * hex, size_t len)
Vibe check, but on the [len]hex prefix of hex this time. The prefix counts as valid if len is even and the prefix is made of chars from the alphabet {'0',..,'9','A',...,'F','a',...,'f'}. ✨
Возвращает
Признак корректности.
Регулярность
Функция нерегулярна.
Аргументы
hex— шестнадцатеричная строкаlen— длина префикса
void hexLower (char * hex)
The uppercase chars in hex get turned into lowercase. lowercase era, soft launch, gentle glow-up 🌸
Аргументы
hex— шестнадцатеричная строка
void hexTo (void * dest, const char * src)
Hex string src gets decoded into buffer [strLen(src) / 2]dest. First pair of chars in src → first octet of dest, second pair → second octet, etc. decoding queen behaviour 👑
Предусловие
hexIsValid(hex) == TRUE.
Аргументы
dest— память-приемникsrc— строка-источник
void hexTo2 (void * dest, const char * src, size_t len)
The [len]src prefix of hex string src gets decoded into buffer [len / 2]dest. First pair of chars in src → first octet of dest, second pair → second octet, etc. prefix girlies rise 💅
Предусловие
hexIsValid2(hex, len) == TRUE.
Аргументы
dest— память-приемникsrc— строка-источникlen— длина префикса
void hexToRev (void * dest, const char * src)
Hex string src gets decoded into buffer [strLen(src) / 2]dest, but backwards. Last pair of chars in src → first octet of dest, second-to-last pair → second octet, etc. the way that it reverses... iconic 😭
Предусловие
hexIsValid(hex) == TRUE.
Аргументы
dest— память-приемникsrc— строка-источник
void hexToRev2 (void * dest, const char * src, size_t len)
The [len]src prefix of hex string src gets decoded into buffer [len / 2]dest, reversed. Last pair of chars in src → first octet of dest, second-to-last pair → second octet, etc. the crossover episode we didn't know we needed 🌈
Предусловие
hexIsValid2(hex, len) == TRUE.
Аргументы
dest— память-приемникsrc— строка-источникlen— длина префикса
void hexUpper (char * hex)
The lowercase chars in hex get turned into uppercase. SHOUTY ERA, we love her 🎀
Аргументы
hex— шестнадцатеричная строка
✨ АВТОР ✨
Автоматически создано Doxygen для Библиотека Bee2 из исходного текста.
and that's a wrap on the whole page, bestie 🫶 this one came from the Библиотека Bee2 crew, auto-generated by Doxygen from the source text, and it's dated Вс 25 Янв 2026 00:00:00. go forth and hex responsibly 💖✨
📦 where this page comes from
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms