safec 3.15
Safe C Library - ISO TR24731 Bounds Checking Interface
Loading...
Searching...
No Matches
u8sscanf_s.c File Reference
#include "safe_u8_lib.h"
Include dependency graph for u8sscanf_s.c:

Functions

EXPORT int u8sscanf_s (const char8_t *restrict buffer, const char *restrict fmt,...)
 The u8sscanf_s function reads a formatted utf-8 string, and writes to a list of arguments.

Function Documentation

◆ u8sscanf_s()

EXPORT int u8sscanf_s ( const char8_t *restrict buffer,
const char *restrict fmt,
... )

The u8sscanf_s function reads a formatted utf-8 string, and writes to a list of arguments.

UTF-8 is byte-compatible with the underlying scanner, so this is otherwise identical to sscanf_s(), except that – unlike the rest of the scanf_s family – the c, s, and %[ conversion specifiers here require their Annex K companion rsize_t destination- size argument: u8sscanf_s() always consumes and enforces it, since it has the whole source buffer available up front to do so safely (unlike the streaming scanf_s variants, where that two-argument convention is documented but not yet enforced).

Parameters
[in]bufferpointer to a NUL-terminated utf-8 string to read from
[in]fmtformat-control string.
[out]...arguments to write to; every c, s, and %[ is followed by an rsize_t giving the size of its destination array
Precondition
Neither buffer nor fmt shall be a null pointer.
buffer shall not contain an illegal or truncated UTF-8 sequence.
c, s, and %[ conversion specifiers each expect two arguments (the usual pointer and a value of type rsize_t indicating the size of the receiving array, which may be 1 when reading with a c into a single character).
Returns
Number of receiving arguments successfully assigned, or EOF if read failure occurs before the first receiving argument was assigned or if there is a runtime constraint violation.
Return values
>0 on success, the number of arguments assigned
EOFon error, or when buffer contains illegal UTF-8 or a c/s/%[ destination is too small (errno set to EILSEQ resp. ESNOSPC)
See also
vu8sscanf_s(), sscanf_s()