safec  3.0
Safe C Library - ISO TR24731 Bounds Checking Interface
towfc_s.c File Reference
#include "safe_str_lib.h"
+ Include dependency graph for towfc_s.c:

Functions

wint_t _towcase (wint_t wc, int lower)
 
int iswfc (wint_t wc)
 
int _towfc_single (wchar_t *restrict dest, const wint_t src)
 
int towfc_s (wchar_t *restrict dest, rsize_t dmax, const wint_t src)
 towfc_s() converts a wide character to fully fold-cased (lowercased with possible expansions), according to the Unicode 10.0 CaseFolding table. More...
 

Variables

struct {
   unsigned short   upper
 
   unsigned short   lower1
 
   unsigned short   lower2
 
tbl2 []
 iswfc() checks the uppercase character for a mapping to foldcase, returning the number of new wide character codepoints needed. More...
 
struct {
   unsigned short   upper
 
   unsigned short   lower1
 
   unsigned short   lower2
 
   unsigned short   lower3
 
tbl3 []
 

Function Documentation

◆ _towcase()

wint_t _towcase ( wint_t  wc,
int  lower 
)

◆ iswfc()

int iswfc ( wint_t  wc)

◆ _towfc_single()

int _towfc_single ( wchar_t *restrict  dest,
const wint_t  src 
)

◆ towfc_s()

int towfc_s ( wchar_t *restrict  dest,
rsize_t  dmax,
const wint_t  src 
)

towfc_s() converts a wide character to fully fold-cased (lowercased with possible expansions), according to the Unicode 10.0 CaseFolding table.

Even in most the unsuccessul cases, just not with with ESNULLP and ESZEROL dest is being written to.

As of Unicode 10.0 there are no possible results as surrogate pairs with sizeof(wchar_t)==2, all results are below U+FFFF.

Parameters
[out]destwide string buffer to store result
[in]dmaxmaximum size of dest, should be 4. (3 + NULL)
[in]srcwide character to convert to lowercase
Precondition
dest shall not be a null pointer.
dmax shall be bigger than 3
dmax shall not be greater than RSIZE_MAX_WSTR.
Return values
>=0on successful operation, returns the number of converted wide characters: 0-3
-ESNULLPwhen dest is NULL pointer
-ESZEROLwhen dmax = 0
-ESLEMINwhen dmax < 4
-ESLEMAXwhen dmax > RSIZE_MAX_WSTR
-ESNOTFNDwhen no mapping for src was found, iswfc is wrong.
See also
iswfc(), wcsfc_s(), towlower()

Variable Documentation

◆ upper

unsigned short upper

◆ lower1

unsigned short lower1

◆ lower2

unsigned short lower2

◆ tbl2

const { ... } tbl2[]

iswfc() checks the uppercase character for a mapping to foldcase, returning the number of new wide character codepoints needed.

The usual iswupper(wc) case returns 1, and the special 104 full folding cases as specified in Unicode 10.0 CaseFolding.txt return either 2 or 3.

Parameters
[in]wcunicode character codepoint
Return values
0when there is no corresponding lowercase mapping.
1when there is a corresponding common or simple foldcase mapping.
2a full case-folding expands to 2 characters
3a full case-folding expands to 3 characters
See also
towfc_s(), wcsfc_s(), towupper()

◆ lower3

unsigned short lower3

◆ tbl3

const { ... } tbl3[]
Initial value:
= {
{ 0x0390, 0x03B9,0x0308,0x0301 },
{ 0x03B0, 0x03C5,0x0308,0x0301 },
{ 0x1F52, 0x03C5,0x0313,0x0300 },
{ 0x1F54, 0x03C5,0x0313,0x0301 },
{ 0x1F56, 0x03C5,0x0313,0x0342 },
{ 0x1FB7, 0x03B1,0x0342,0x03B9 },
{ 0x1FC7, 0x03B7,0x0342,0x03B9 },
{ 0x1FD2, 0x03B9,0x0308,0x0300 },
{ 0x1FD3, 0x03B9,0x0308,0x0301 },
{ 0x1FD7, 0x03B9,0x0308,0x0342 },
{ 0x1FE2, 0x03C5,0x0308,0x0300 },
{ 0x1FE3, 0x03C5,0x0308,0x0301 },
{ 0x1FE7, 0x03C5,0x0308,0x0342 },
{ 0x1FF7, 0x03C9,0x0342,0x03B9 },
{ 0xFB03, 0x0066,0x0066,0x0069 },
{ 0xFB04, 0x0066,0x0066,0x006C },
{ 0, 0,0,0 }
}