safec
3.2
Safe C Library - ISO TR24731 Bounds Checking Interface
|
#include "safe_str_lib.h"
Functions | |
static int | _is_lt_accented (uint32_t wc) |
EXPORT errno_t | wcsfc_s (wchar_t *restrict dest, rsize_t dmax, wchar_t *restrict src, rsize_t *restrict lenp) |
Converts the wide string via full case-folding NFD normalized to lowercase. More... | |
|
inlinestatic |
EXPORT errno_t wcsfc_s | ( | wchar_t *restrict | dest, |
rsize_t | dmax, | ||
wchar_t *restrict | src, | ||
rsize_t *restrict | lenp | ||
) |
Converts the wide string via full case-folding NFD normalized to lowercase.
The conversion stops at the first null or after dmax characters. The conversion is determined by the LC_CTYPE category setting of the locale. Other characters are not affected. fold-case performs full case folding, i.e. if iswfc() of a character > 1, the length of dest might be greater than the length of src (max 4 per char), the conversion is done via towfc_s()
and Unicode 10.0, the Unicode special-casing rules are obeyed, and composed characters are normalized to NFD via wcsnorm_decompose_s()
and wcsnorm_reorder_s()
. If not, the conversion is per character done via normal towlower()
. Note that decomposition creates larger strings, typically 2-3 chars more.
With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled.
SpecialCasing checks for conditional boundary context at the begin or end of certain characters (final greek sigma), and locale sensitive rules for the Lithuanian and the Turkish/Azeri I-dot.
Composed characters are checked for the left-hand-side of the Decomposition_Mapping Unicode property, which means the codepoint will be normalized to NFD if any codepoint is composed. Technically only FCD as all FC expansions are already properly ordered, and all mangled marks will not be reordered, as the have the same Combining Class.
[out] | dest | wide string to hold the result (~130% larger than src) |
[in] | dmax | maximum result buffer size |
[in] | src | wide string |
[out] | lenp | pointer to length of the result, may be NULL |
EOK | on successful operation |
ESNULLP | when dest or src is NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_WSTR or a cp > 0x10ffff |
ESNOSPC | when dmax is too small for the decomposition. *lenp is still written, to know how much space is needed. |
ESNOTFND | Internal error as returned by towfc_s() for multi-char foldings. happens only when the internal implementations of iswfc() and towfc_s() are mismatched. |