AxlStr — String Utilities
See AxlData — Data Structures for an overview of all data modules including string utilities, string builder, collections, JSON, and cache.
Header: <axl/axl-str.h>
API Reference
Functions
-
size_t axl_strlen(const char *s)
Get string length. NULL returns 0.
axl-str.h:
String utilities. All char * functions operate on UTF-8 strings (which are a superset of ASCII). Case-insensitive operations (axl_strcasecmp, axl_strcasestr) fold ASCII letters only — they do not handle full Unicode case mapping.
UCS-2 (unsigned short *) functions are in the _w section at the bottom of this file — these are for UEFI internal use. Consumer code should use UTF-8 throughout.
All allocated results are freed with axl_free().
- Parameters:
s – NUL-terminated string, or NULL
-
int axl_strcmp(const char *a, const char *b)
Compare two strings.
- Parameters:
a – first string
b – second string
- Returns:
<0, 0, or >0.
-
static inline bool axl_streql(const char *a, const char *b)
Test if two strings are equal. NULL-safe.
Shorthand for
axl_strcmp(a, b) == 0.- Returns:
true if equal.
-
int axl_strncmp(const char *a, const char *b, size_t n)
Compare at most
bytes of two strings.
- Parameters:
a – first string
b – second string
n – max bytes to compare
- Returns:
<0, 0, or >0.
-
int axl_strcasecmp(const char *a, const char *b)
Case-insensitive string comparison (ASCII case folding only).
- Parameters:
a – first string
b – second string
- Returns:
<0, 0, or >0.
-
size_t axl_strnlen(const char *s, size_t maxlen)
Bounded string length. Like POSIX strnlen().
Returns the number of bytes in s before the first NUL, capped at maxlen. NULL-safe (returns 0). Useful for length-bounded scans of fixed-width buffers where running off the end would be a read past the buffer.
- Parameters:
s – NUL-terminated string, or NULL
maxlen – maximum bytes to scan
-
static inline bool axl_isdigit(int c)
True for ASCII ‘0’..’9’.
-
static inline bool axl_isxdigit(int c)
True for ASCII ‘0’..’9’, ‘a’..’f’, ‘A’..’F’.
-
static inline bool axl_isalpha(int c)
True for ASCII ‘a’..’z’ or ‘A’..’Z’.
-
static inline bool axl_isalnum(int c)
True for ASCII alphanumeric.
-
static inline bool axl_isspace(int c)
True for ASCII whitespace: space, tab, LF, CR, VT, FF.
-
static inline int axl_tolower(int c)
Lowercase one ASCII char; non-letters returned unchanged.
-
static inline int axl_toupper(int c)
Uppercase one ASCII char; non-letters returned unchanged.
-
static inline int axl_hex_nibble(int c)
Decode one ASCII hex digit to its integer value.
Accepts ‘0’..’9’, ‘a’..’f’, ‘A’..’F’. Returns -1 for any other input — callers can use the return type as both a value and a validity check.
-
int axl_hex_parse_u64(const char *s, size_t max_chars, uint64_t *out)
Parse a run of ASCII hex digits as an unsigned 64-bit integer.
Reads up to
max_charshex digits fromsintoout, stopping at the first non-hex byte. The buffer need not be NUL-terminated as long as it has at leastmax_charsbytes available; this lets the function operate on arbitrary-length slices of larger buffers.max_charsis treated as a strict upper bound. Pass 0 only if you want an immediate failure (returns -1 — useful when callers pass a runtime length that may legitimately be empty).Useful for parsing hex fields embedded in larger strings — chunk sizes in HTTP
Transfer-Encoding: chunked, the leading hex fields of a PCI BDF address, JSON\uXXXXescapes, etc.- Parameters:
s – Input buffer; reading starts at
s[0].max_chars – Strict upper bound on digits to consume.
out – Receives the parsed value on success.
- Returns:
Number of digits actually consumed (>= 1) on success, or -1 if no hex digit was found at the start, or if the value would overflow a uint64_t.
-
void *axl_memcpy(void *dst, const void *src, size_t n)
Copy
bytes from
src to dst.Regions must not overlap. NULL-safe: returns dst if either is NULL.
- Parameters:
dst – destination
src – source
n – byte count
- Returns:
dst.
-
void *axl_memset(void *dst, int c, size_t n)
Fill n bytes of dst with byte c.
- Parameters:
dst – destination
c – fill byte
n – byte count
- Returns:
dst.
-
void *axl_memmove(void *dst, const void *src, size_t n)
Copy n bytes, handling overlapping regions. Like memmove().
- Parameters:
dst – destination
src – source
n – byte count
- Returns:
dst.
-
int axl_memcmp(const void *a, const void *b, size_t n)
Compare n bytes of memory. Like memcmp().
- Parameters:
a – first buffer
b – second buffer
n – byte count
- Returns:
<0, 0, or >0.
-
void *axl_memmem(const void *haystack, size_t haystack_len, const void *needle, size_t needle_len)
Find the first occurrence of
needleinhaystack.Like the GNU
memmemextension. Linear byte-by-byte scan; fine for the sizes we typically search (firmware tables, rom images, signature blocks) but not designed for megabyte-scale inputs.- Parameters:
haystack – buffer to search
haystack_len – buffer length in bytes
needle – pattern to find
needle_len – pattern length in bytes
- Returns:
pointer to the first match inside
haystack, or NULL ifneedleis not present, any input is NULL, orneedle_lenis 0 / larger thanhaystack_len.
-
int axl_snprintf(char *buf, size_t size, const char *fmt, ...)
Format into a fixed buffer. Like snprintf().
Uses AXL’s own printf engine (standard C format specifiers). Always NUL-terminates if size > 0.
- Parameters:
buf – output buffer
size – buffer size
fmt – printf-style format string
- Returns:
number of bytes that would have been written (excluding NUL), regardless of buffer size (allows truncation detection).
-
int axl_format_bytes(uint64_t value, char *buf, size_t buf_size)
Format a byte count into a human-readable string.
Picks the largest IEC binary unit (KiB / MiB / GiB / TiB) that yields a non-fractional integer (12884901888 → “12 GiB”). For sizes that don’t divide evenly, falls back to the largest unit whose floor is non-zero and appends the raw byte count in parentheses (e.g. 1500 → “1 KiB (1500 B)”). Sub-KiB values are always rendered in bytes (512 → “512 B”).
Standard snprintf-style return semantics: the value returned is the length the formatted string would have if
buf_sizewere unlimited. If that value is >=buf_size, the output was truncated and the buffer holds a NUL-terminated prefix.- Parameters:
value – byte count to format.
buf – output buffer; NUL-terminated on return when
buf_size> 0.buf_size – buffer capacity in bytes.
- Returns:
length the formatted string would occupy excluding NUL (== or <
buf_sizeon success, >buf_sizeon truncation), or -1 ifbufis NULL orbuf_sizeis 0.
-
size_t axl_strlcpy(char *dst, const char *src, size_t dst_size)
Copy src into dst, guaranteeing NUL-termination.
At most dst_size-1 characters are copied. Like BSD strlcpy / g_strlcpy.
- Parameters:
dst – destination buffer
src – source string
dst_size – total size of dst (including NUL)
- Returns:
length of src (allows truncation detection: if return >= dst_size, output was truncated).
-
size_t axl_strlcat(char *dst, const char *src, size_t dst_size)
Append src to dst, guaranteeing NUL-termination.
Like BSD strlcat / g_strlcat.
- Parameters:
dst – destination buffer (must be NUL-terminated)
src – string to append
dst_size – total size of dst (including NUL)
- Returns:
attempted total length (dst_len + src_len). If return >= dst_size, output was truncated.
-
char *axl_strndup(const char *s, size_t n)
Duplicate at most n bytes of s into a new NUL-terminated string.
Caller frees with axl_free(). NULL-safe: returns NULL if s is NULL.
- Parameters:
s – source string
n – maximum bytes to copy
- Returns:
new string, or NULL on failure.
-
char **axl_strsplit(const char *str, char delimiter)
Split a string by a delimiter character.
Returns a NULL-terminated array of newly allocated strings. Free the result with axl_strfreev().
- Parameters:
str – string to split
delimiter – delimiter character
- Returns:
array of strings, or NULL on failure.
-
void axl_strfreev(char **arr)
Free a NULL-terminated string array from axl_strsplit.
- Parameters:
arr – array to free (NULL-safe)
-
char *axl_strjoin(const char *separator, const char **arr)
Join a NULL-terminated string array with a separator.
Caller frees the result with axl_free().
- Parameters:
separator – separator between elements
arr – NULL-terminated array of strings
- Returns:
new string, or NULL on failure.
-
char *axl_strjoinv(const char *separator, size_t count, const char *const argv[])
Join a counted string array with a separator (argv shape).
Variant of axl_strjoin for callers that already have a count + argv pair (typically
argc, argvfrom a UEFI shell entry point). Avoids the small reshape allocation needed to build a NULL-terminated copy. Allcountelements of argv must be non-NULL; passingNULLelements is undefined.count== 0 returns an empty allocated string (a 1-byte buffer holding a single NUL). argv may be NULL only whencountis 0.Caller frees the result with axl_free().
- Parameters:
separator – separator between elements
count – number of elements in argv
argv – element pointers; non-NULL when count>0
- Returns:
new string, or NULL on failure.
-
char *axl_strstrip(char *str)
Trim leading and trailing ASCII whitespace in place.
Modifies the string by shifting content and NUL-terminating. Returns the input pointer for convenience.
- Parameters:
str – string to trim (modified in place)
- Returns:
str (same pointer).
-
char *axl_strchr(const char *s, int c)
Find first occurrence of character c in s.
Like strchr(). Returns pointer to matching character, or NULL.
- Parameters:
s – string to search
c – character to find
- Returns:
pointer to first c in s, or NULL if not found.
-
char *axl_strstr(const char *haystack, const char *needle)
Find first occurrence of needle in haystack.
Like strstr(). Searches the entire NUL-terminated string.
- Parameters:
haystack – string to search
needle – substring to find
- Returns:
pointer to match, or NULL if not found.
-
char *axl_strncpy(char *dst, const char *src, size_t n)
Copy src to dst, NUL-padding to n bytes.
Like strncpy(). If src is shorter than n, the remainder is filled with NUL bytes. Does NOT guarantee NUL-termination if src is longer than n. Prefer axl_strlcpy() for safe copying with guaranteed NUL-termination.
- Parameters:
dst – destination buffer
src – source string
n – max bytes to write
- Returns:
dst.
-
char *axl_strstr_len(const char *haystack, long long haystack_len, const char *needle)
Find first occurrence of needle in haystack.
Searches at most haystack_len bytes. Pass -1 to search the entire NUL-terminated string.
- Parameters:
haystack – string to search
haystack_len – max bytes to search (-1 for all)
needle – substring to find
- Returns:
pointer to match, or NULL if not found.
-
char *axl_strrstr(const char *haystack, const char *needle)
Find last occurrence of needle in haystack.
- Parameters:
haystack – string to search
needle – substring to find
- Returns:
pointer to match, or NULL if not found.
-
char *axl_strrstr_len(const char *haystack, long long haystack_len, const char *needle)
Find last occurrence of needle in first haystack_len bytes.
- Parameters:
haystack – string to search
haystack_len – max bytes to search (-1 for all)
needle – substring to find
- Returns:
pointer to match, or NULL if not found.
-
char *axl_strcasestr(const char *haystack, const char *needle)
Case-insensitive substring search (ASCII case folding only).
Finds the first occurrence of needle in haystack, ignoring ASCII letter case. NULL-safe: returns NULL if either argument is NULL.
- Parameters:
haystack – string to search
needle – substring to find (case-insensitive)
- Returns:
pointer to match, or NULL if not found.
-
char *axl_strcasestr_len(const char *haystack, long long haystack_len, const char *needle)
Length-bounded case-insensitive substring search.
Like axl_strcasestr but treats haystack as a byte slice of haystack_len bytes — the haystack does NOT need to be NUL-terminated. Pass
-1for haystack_len to default to NUL-terminated semantics (mirror of axl_strstr_len).Useful for searching slices into a larger buffer (e.g. lines delivered by
AxlLineReaderthat point into a working buffer without their own NUL terminator).- Returns:
pointer to match, or NULL if not found.
-
bool axl_fnmatch(const char *pattern, const char *string)
Glob-style pattern matching.
Matches string against pattern using shell glob rules:
*matches zero or more characters,?matches exactly one,[abc]matches a character class,[a-z]matches a range. Matching is case-sensitive. NULL-safe: returns false if either argument is NULL.- Parameters:
pattern – glob pattern
string – string to match against
- Returns:
true if string matches pattern.
-
bool axl_str_has_prefix(const char *str, const char *prefix)
Test if str starts with prefix.
- Parameters:
str – string to test
prefix – prefix to check for
- Returns:
true if str begins with prefix.
-
bool axl_str_has_suffix(const char *str, const char *suffix)
Test if str ends with suffix.
- Parameters:
str – string to test
suffix – suffix to check for
- Returns:
true if str ends with suffix.
-
bool axl_str_is_ascii(const char *str)
Test if string is pure ASCII (all bytes 0x00-0x7F).
- Parameters:
str – string to test
- Returns:
true if all bytes are ASCII.
-
int axl_strcmp0(const char *str1, const char *str2)
NULL-safe string comparison.
Two NULLs are equal. NULL sorts before non-NULL.
- Parameters:
str1 – first string (may be NULL)
str2 – second string (may be NULL)
- Returns:
negative, zero, or positive (like strcmp).
-
bool axl_str_equal(const void *v1, const void *v2)
Byte-by-byte string equality test. (GLib: g_str_equal)
Parameters are void* so this can be used directly as a hash table equality function. Both strings must be non-NULL.
- Parameters:
v1 – first string (cast to const char *)
v2 – second string (cast to const char *)
- Returns:
true if strings are equal.
-
size_t axl_str_hash(const void *key)
FNV-1a hash of a NUL-terminated string. (GLib: g_str_hash)
Void-pointer signature matches AxlHashFunc so it can be handed directly to axl_hash_table_new.
- Parameters:
key – NUL-terminated string (cast to const char *)
- Returns:
hash value.
-
int axl_strncasecmp(const char *s1, const char *s2, size_t n)
Case-insensitive comparison, length-bounded (ASCII only).
Compares at most n bytes. ASCII letters only (A-Z, a-z).
- Parameters:
s1 – first string
s2 – second string
n – max bytes to compare
- Returns:
negative, zero, or positive (like strncmp).
-
bool axl_strv_contains(const char *const *strv, const char *str)
Check if a NULL-terminated string array contains str.
- Parameters:
strv – NULL-terminated string array
str – string to search for
- Returns:
true if str is found in strv.
-
bool axl_strv_equal(const char *const *strv1, const char *const *strv2)
Check if two NULL-terminated string arrays are identical.
Both arrays must be non-NULL. Compares element-by-element.
- Parameters:
strv1 – first array
strv2 – second array
- Returns:
true if arrays have the same elements in the same order.
-
unsigned short *axl_utf8_to_ucs2(const char *s)
Convert a UTF-8 string to UCS-2.
Handles BMP characters (U+0000..U+FFFF). Caller frees with axl_free(). The returned type (unsigned short *) matches UEFI’s CHAR16.
- Parameters:
s – UTF-8 string, or NULL
- Returns:
newly allocated UCS-2 string, or NULL if s is NULL or allocation fails.
-
size_t axl_utf8_to_ucs2_buf(const char *src, unsigned short *dst, size_t dst_count)
Widen an ASCII/UTF-8 string to UCS-2 in a caller-provided buffer.
No allocation. Copies each byte as a 16-bit character. Suitable for stack buffers in performance-sensitive code (logging, console output).
- Parameters:
src – UTF-8 source string
dst – destination UCS-2 buffer
dst_count – capacity of dst in characters (including NUL)
- Returns:
number of characters written (excluding NUL terminator).
-
char *axl_ucs2_to_utf8(const unsigned short *s)
Convert a UCS-2 string to UTF-8.
Caller frees with axl_free().
- Parameters:
s – UCS-2 (unsigned short *) string, or NULL
- Returns:
newly allocated UTF-8 string, or NULL if s is NULL or allocation fails.
-
size_t axl_ucs2_to_utf8_buf(const unsigned short *src, char *dst, size_t dst_size)
Narrow a UCS-2 string to UTF-8 in a caller-provided buffer.
No allocation. Encodes BMP characters with full UTF-8 multi-byte sequences. Truncates cleanly at dst_size with a NUL terminator (never writes a partial multi-byte sequence). Suitable for stack buffers in performance-sensitive code (variable names, console paths) — companion to axl_utf8_to_ucs2_buf.
- Parameters:
src – UCS-2 source string
dst – destination UTF-8 buffer
dst_size – capacity of dst in bytes (including NUL)
- Returns:
number of bytes written to dst (excluding NUL).
-
char *axl_base64_encode(const void *data, size_t len)
Base64-encode binary data.
Caller frees with axl_free().
- Parameters:
data – input bytes
len – input length
- Returns:
NUL-terminated base64 string, or NULL on failure.
-
int axl_base64_decode(const char *b64, void **out, size_t *out_len)
Decode a base64 string.
- Parameters:
b64 – base64 string
out – (out): pointer to decoded data (caller frees with axl_free)
out_len – (out): decoded data length
- Returns:
AXL_OK on success, AXL_ERR on invalid input.
-
int axl_str_to_u64(const char *nptr, int base, uint64_t *out, const char **endptr)
Parse an unsigned 64-bit integer with overflow detection.
Skips leading whitespace, then accepts an optional “0x”/”0X” hex prefix. The
baseparameter selects the radix (2-36, or 0 to auto-detect: “0x”/”0X” prefix → base 16, otherwise base 10 — this does NOT decode leading “0” as octal, unlike C strtol). A leading ‘+’ is accepted; a leading ‘-’ is rejected for unsigned variants.Returns -1 on syntax error (no digits, invalid digit for base, sign for unsigned), or out-of-range for the target type. On success,
outreceives the value andendptr(if non-NULL) receives a pointer just past the last consumed character. On error,outis unchanged and *endptr(if non-NULL) is set tonptr.- Parameters:
nptr – number string
base – 0 (auto), or 2-36
out – [out] parsed value
endptr – [out, optional] past last consumed char
- Returns:
AXL_OK on success, AXL_ERR on error.
-
int axl_str_to_u32(const char *nptr, int base, uint32_t *out, const char **endptr)
Like axl_str_to_u64 but the value must fit in uint32_t.
-
int axl_str_to_u16(const char *nptr, int base, uint16_t *out, const char **endptr)
Like axl_str_to_u64 but the value must fit in uint16_t.
-
int axl_str_to_u8(const char *nptr, int base, uint8_t *out, const char **endptr)
Like axl_str_to_u64 but the value must fit in uint8_t.
-
int axl_str_to_s64(const char *nptr, int base, int64_t *out, const char **endptr)
Parse a signed 64-bit integer with overflow detection.
Same shape and rules as axl_str_to_u64, plus an optional leading ‘-’ for negatives. Returns -1 on syntax error or out-of-range.
-
int axl_str_to_s32(const char *nptr, int base, int32_t *out, const char **endptr)
Like axl_str_to_s64 but the value must fit in int32_t.
-
int axl_str_to_s16(const char *nptr, int base, int16_t *out, const char **endptr)
Like axl_str_to_s64 but the value must fit in int16_t.
-
int axl_str_to_s8(const char *nptr, int base, int8_t *out, const char **endptr)
Like axl_str_to_s64 but the value must fit in int8_t.
-
uint64_t axl_strtou64(const char *s)
Parse an unsigned 64-bit integer (legacy, lossy).
- Deprecated:
Prefer axl_str_to_u64. This wrapper preserves the previous “best effort, return 0 on any failure” semantics for existing callers — overflow wraps silently, “abc” returns 0 indistinguishable from “0”, and partial parses (“123abc” returns 123) are accepted.
Handles “0x” prefix for hex. Returns 0 on NULL or invalid input.
- Parameters:
s – number string (decimal or “0x” hex)
-
int axl_strtou64_with_offset(const char *s, uint64_t *out)
Parse a hex/decimal value with an optional
+offsetsuffix.Common pattern in low-level CLI tools that read or write hardware registers and want to express a target as
base+offsetin a single argv token. Accepts:“0x100” → base = 0x100, offset = 0
”256” → base = 256, offset = 0
”0x100+0x10” → base = 0x100, offset = 0x10
”256+16” → base = 256, offset = 16
”0x1000+0xFF” → 0x1000 + 0xFF = 0x10FF
Strict: any unconsumed characters after the optional offset cause a parse error. Overflow on either component or on the sum returns -1. Leading whitespace is allowed (matches
axl_str_to_u64) but not whitespace around the+. NULL input returns -1.- Parameters:
s – number string with optional “+offset” suffix
out – [out] parsed value (base + offset)
- Returns:
AXL_OK on success (with out populated), AXL_ERR on parse error.
-
void axl_str_reader_init(AxlStrReader *r, const char *s)
Initialize a reader from a NUL-terminated string.
NULL s yields a reader at EOF with ok = true (consumers see “nothing to parse, no error” — typically distinguished by checking eof() AND remaining() before relying on a successful parse).
-
void axl_str_reader_init_n(AxlStrReader *r, const char *s, size_t n)
Initialize a reader from a length-bounded buffer.
Use when the input is not NUL-terminated (slice into a larger buffer, embedded NULs allowed). NULL s with n > 0 is a programming error and yields an at-EOF reader with ok = false.
-
bool axl_str_reader_eof(const AxlStrReader *r)
True iff the cursor is at end-of-input. NULL r returns true.
-
size_t axl_str_reader_remaining(const AxlStrReader *r)
Bytes between the cursor and end. 0 at EOF or NULL r.
-
char axl_str_reader_peek(const AxlStrReader *r)
Peek the next byte without advancing. Returns 0 at EOF or when the reader is in error state — distinguish via eof() if a 0 byte is legitimate input.
-
bool axl_str_reader_skip_ws(AxlStrReader *r)
Skip whitespace (,
\t,\r,\n,\f,\v).Always succeeds (skipping zero bytes is fine). Doesn’t touch ok. Use this between fields where the input grammar allows whitespace.
-
bool axl_str_reader_consume_char(AxlStrReader *r, char c)
Consume a literal character.
On match, advances past it and returns true. On mismatch (or EOF, or prior error), sets ok = false and returns false; the cursor is not advanced. Idempotent in the sense that ok-false reader stays ok-false.
-
bool axl_str_reader_consume_str(AxlStrReader *r, const char *literal)
Consume an exact literal string.
Sets ok = false on mismatch (no partial consume). NULL or empty literal is a no-op that returns true.
-
bool axl_str_reader_take_until(AxlStrReader *r, char delim, const char **out, size_t *out_len)
Take bytes up to (but not including) delim, then consume delim.
On success, *out points into the input (no allocation; valid for the lifetime of the source string) and *out_len is the slice length, which may be 0 (e.g. the input begins with delim). If delim is not found before EOF, sets ok = false.
- Parameters:
out – [out, optional] start of the slice
out_len – [out, optional] slice length
-
bool axl_str_reader_take_while(AxlStrReader *r, bool (*pred)(char), const char **out, size_t *out_len)
Take bytes while pred returns true.
Always succeeds; a zero-length take is not an error (returns true with *out_len = 0). Use the result to distinguish “matched nothing” from “matched something” if your grammar requires at least one char.
- Parameters:
out – [out, optional] start of the slice
out_len – [out, optional] slice length
-
bool axl_str_reader_take_u64(AxlStrReader *r, int base, uint64_t *out)
Parse a u64 literal at the cursor.
Behavior matches
axl_str_to_u64:base = 0: auto-detect “0x”/”0X” hex prefix, else decimal.
base = 16: accepts an optional “0x”/”0X” prefix and otherwise reads hex digits.
base in [2..36] (other than 16): reads digits only, no prefix handling.
Stops at the first non-digit and advances the cursor past the consumed digits (and prefix, if any). Sets ok = false and leaves the cursor unchanged if no digits are present or the value overflows u64.
- Parameters:
base – 0 (auto-detect), 16 (with optional 0x), or 2..36
out – [out] parsed value
-
bool axl_str_reader_take_ident(AxlStrReader *r, const char **out, size_t *out_len)
Take a C identifier:
[A-Za-z_][A-Za-z0-9_]*.*out points into the input; *out_len is the identifier length. Sets ok = false when the leading char isn’t a valid identifier start (a digit, punctuation, EOF).
- Parameters:
out – [out, optional]
out_len – [out, optional]
-
int axl_sscanf(const char *str, const char *fmt, ...)
Scan str against fmt and assign to the listed pointers.
- Returns:
number of conversions stored, or -1 on malformed format.
-
int axl_vsscanf(const char *str, const char *fmt, va_list ap)
va_list variant of axl_sscanf.
-
size_t axl_wcslen(const unsigned short *s)
Get UCS-2 string length. NULL returns 0.
- Parameters:
s – UCS-2 string, or NULL
- Returns:
number of characters (not including NUL).
-
int axl_wcscmp(const unsigned short *a, const unsigned short *b)
Compare two UCS-2 strings.
NULL-safe: NULL sorts before non-NULL. Two NULLs are equal.
- Parameters:
a – first string
b – second string
- Returns:
<0, 0, or >0.
-
static inline bool axl_wcseql(const unsigned short *a, const unsigned short *b)
Test if two UCS-2 strings are equal. NULL-safe.
Shorthand for
axl_wcscmp(a, b) == 0.- Returns:
true if equal.
-
void axl_wcscpy(unsigned short *dst, const unsigned short *src, size_t dst_count)
Copy UCS-2 string with size limit. Guarantees NUL-termination.
- Parameters:
dst – destination buffer
src – source string
dst_count – destination buffer size in characters
-
struct AxlStrReader
- #include <axl-str.h>
Cursor parser state. Initialize via axl_str_reader_init / _init_n. Fields are exposed for convenience inspection (
r.ok,r.p); don’t mutate them directly outside the helpers.