cIsBase64
inline bool cIsBase64(unsigned char c);
Tests whether one byte is a Base64 alphabet character. The padding character = and whitespace are not alphabet characters.
Data & serialization
Base64, Base62, URL encoding, Unicode conversion, and compact data tags.
#include <mc/encode.h>Encoding functions operate on bytes unless the signature explicitly describes text. Decode URL escapes separately from parsing a full URL.
inline bool cIsBase64(unsigned char c);
Tests whether one byte is a Base64 alphabet character. The padding character = and whitespace are not alphabet characters.
inline cstr cToBase64(const char* buf, size_t bytes);
template<class T> inline cstr cToBase64(const T& x);
Encodes bytes with the standard Base64 alphabet and = padding, without line breaks. The object overload encodes its raw in-memory bytes rather than a portable serialized representation.
inline cstr cFromBase64(const char* buf, size_t bytes);
template<class T> inline T cFromBase64(const cstr& s);
Decodes padded or unpadded Base64, rejecting invalid characters, lengths, padding, and nonzero unused bits. The typed overload requires a trivially copyable type and an exact decoded size; it reconstructs that type’s native object representation.
template<class T> inline std::expected<T, CError> cTryFromBase64(const cstr& s);
inline std::expected<cstr, CError> cTryFromBase64(const char* buf, size_t size);
Returns std::expected containing the decoded result or a CError. The typed overload requires a trivially copyable object of the exact decoded size.
Encodes a nonnegative integer with digits 0–9, a–z, and A–Z. Current behavior emits least-significant digits first and represents zero as an empty string, so it is not conventional positional Base62 text.
template<class T> inline cstr cDataTag(const T& x);
Encodes a compact printable tag from data.
Percent-encodes bytes outside this helper’s preserved character set, stopping at the first NUL. It leaves several reserved characters unchanged, including :, =, and ?; it is not a general-purpose encoder for individual query values.
Decodes percent escapes until the first NUL, rejecting incomplete or invalid hex pairs. A plus sign remains a plus sign rather than becoming a space.
inline cstr cFromUnicode(uint32_t u);
Encodes one Unicode scalar value as UTF-8. Surrogates and values above U+10FFFF throw CError.