Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
wctype.h File Reference
#include <_types/_wchar_t.h>
Include dependency graph for wctype.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WEOF   0xffffffffU
 
#define WCTYPE_ALNUM   1
 
#define WCTYPE_ALPHA   2
 
#define WCTYPE_BLANK   3
 
#define WCTYPE_CNTRL   4
 
#define WCTYPE_DIGIT   5
 
#define WCTYPE_GRAPH   6
 
#define WCTYPE_LOWER   7
 
#define WCTYPE_PRINT   8
 
#define WCTYPE_PUNCT   9
 
#define WCTYPE_SPACE   10
 
#define WCTYPE_UPPER   11
 
#define WCTYPE_XDIGIT   12
 

Typedefs

typedef const int * wctrans_t
 
typedef unsigned wint_t
 
typedef unsigned long wctype_t
 

Functions

int iswalnum (wint_t)
 
int iswalpha (wint_t)
 
int iswblank (wint_t)
 
int iswcntrl (wint_t)
 
int iswctype (wint_t, wctype_t)
 
int iswdigit (wint_t)
 
int iswgraph (wint_t)
 
int iswlower (wint_t)
 
int iswprint (wint_t)
 
int iswpunct (wint_t)
 
int iswspace (wint_t)
 
int iswupper (wint_t)
 
int iswxdigit (wint_t)
 
wint_t towctrans (wint_t, wctrans_t)
 
wint_t towlower (wint_t)
 
wint_t towupper (wint_t)
 
wctrans_t wctrans (const char *)
 
wctype_t wctype (const char *)
 

Macro Definition Documentation

◆ WCTYPE_ALNUM

#define WCTYPE_ALNUM   1

Definition at line 17 of file wctype.h.

◆ WCTYPE_ALPHA

#define WCTYPE_ALPHA   2

Definition at line 18 of file wctype.h.

◆ WCTYPE_BLANK

#define WCTYPE_BLANK   3

Definition at line 19 of file wctype.h.

◆ WCTYPE_CNTRL

#define WCTYPE_CNTRL   4

Definition at line 20 of file wctype.h.

◆ WCTYPE_DIGIT

#define WCTYPE_DIGIT   5

Definition at line 21 of file wctype.h.

◆ WCTYPE_GRAPH

#define WCTYPE_GRAPH   6

Definition at line 22 of file wctype.h.

◆ WCTYPE_LOWER

#define WCTYPE_LOWER   7

Definition at line 23 of file wctype.h.

◆ WCTYPE_PRINT

#define WCTYPE_PRINT   8

Definition at line 24 of file wctype.h.

◆ WCTYPE_PUNCT

#define WCTYPE_PUNCT   9

Definition at line 25 of file wctype.h.

◆ WCTYPE_SPACE

#define WCTYPE_SPACE   10

Definition at line 26 of file wctype.h.

◆ WCTYPE_UPPER

#define WCTYPE_UPPER   11

Definition at line 27 of file wctype.h.

◆ WCTYPE_XDIGIT

#define WCTYPE_XDIGIT   12

Definition at line 28 of file wctype.h.

◆ WEOF

#define WEOF   0xffffffffU

Definition at line 15 of file wctype.h.

Typedef Documentation

◆ wctrans_t

typedef const int* wctrans_t

Definition at line 10 of file wctype.h.

◆ wctype_t

typedef unsigned long wctype_t

Definition at line 12 of file wctype.h.

◆ wint_t

typedef unsigned wint_t

Definition at line 11 of file wctype.h.

Function Documentation

◆ iswalnum()

int iswalnum ( wint_t  )

Definition at line 3 of file iswalnum.c.

4 {
5  return iswdigit(wc) || iswalpha(wc);
6 }
int iswdigit(wint_t)
Definition: iswdigit.c:3
int iswalpha(wint_t)
Definition: iswalpha.c:7

References iswalpha(), and iswdigit().

Referenced by iswctype().

Here is the caller graph for this function:

◆ iswalpha()

int iswalpha ( wint_t  )

Definition at line 7 of file iswalpha.c.

8 {
9  if(wc < 0x20000U)
10  {
11  return (table[table[wc >> 8] * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1;
12  }
13  if(wc < 0x2fffeU)
14  {
15  return 1;
16  }
17  return 0;
18 }
static const unsigned char table[]
Definition: iswalpha.c:3

References table.

Referenced by __towcase(), iswalnum(), and iswctype().

Here is the caller graph for this function:

◆ iswblank()

int iswblank ( wint_t  )

Definition at line 4 of file iswblank.c.

5 {
6  return isblank((int)wc);
7 }
int isblank(int ch)
Checks if the given character is a blank character.
Definition: isblank.c:5

References isblank().

Referenced by iswctype().

Here is the caller graph for this function:

◆ iswcntrl()

int iswcntrl ( wint_t  )

Definition at line 3 of file iswcntrl.c.

4 {
5  return (unsigned)wc < 32 || (unsigned)(wc - 0x7f) < 33 || (unsigned)(wc - 0x2028) < 2 ||
6  (unsigned)(wc - 0xfff9) < 3;
7 }

Referenced by iswctype().

Here is the caller graph for this function:

◆ iswctype()

int iswctype ( wint_t  ,
wctype_t   
)

Definition at line 4 of file iswctype.c.

5 {
6  switch(type)
7  {
8  case WCTYPE_ALNUM:
9  return iswalnum(wc);
10  case WCTYPE_ALPHA:
11  return iswalpha(wc);
12  case WCTYPE_BLANK:
13  return iswblank(wc);
14  case WCTYPE_CNTRL:
15  return iswcntrl(wc);
16  case WCTYPE_DIGIT:
17  return iswdigit(wc);
18  case WCTYPE_GRAPH:
19  return iswgraph(wc);
20  case WCTYPE_LOWER:
21  return iswlower(wc);
22  case WCTYPE_PRINT:
23  return iswprint(wc);
24  case WCTYPE_PUNCT:
25  return iswpunct(wc);
26  case WCTYPE_SPACE:
27  return iswspace(wc);
28  case WCTYPE_UPPER:
29  return iswupper(wc);
30  case WCTYPE_XDIGIT:
31  return iswxdigit(wc);
32  }
33  return 0;
34 }
int iswpunct(wint_t)
Definition: iswpunct.c:7
int iswdigit(wint_t)
Definition: iswdigit.c:3
#define WCTYPE_SPACE
Definition: wctype.h:26
#define WCTYPE_DIGIT
Definition: wctype.h:21
int iswprint(wint_t)
Definition: iswprint.c:10
#define WCTYPE_ALPHA
Definition: wctype.h:18
#define WCTYPE_LOWER
Definition: wctype.h:23
#define WCTYPE_CNTRL
Definition: wctype.h:20
int iswxdigit(wint_t)
Definition: iswxdigit.c:3
int iswgraph(wint_t)
Definition: iswgraph.c:3
#define WCTYPE_PUNCT
Definition: wctype.h:25
int iswupper(wint_t)
Definition: iswupper.c:3
#define WCTYPE_UPPER
Definition: wctype.h:27
int iswalnum(wint_t)
Definition: iswalnum.c:3
#define WCTYPE_XDIGIT
Definition: wctype.h:28
#define WCTYPE_PRINT
Definition: wctype.h:24
#define WCTYPE_ALNUM
Definition: wctype.h:17
int iswcntrl(wint_t)
Definition: iswcntrl.c:3
#define WCTYPE_GRAPH
Definition: wctype.h:22
int iswblank(wint_t)
Definition: iswblank.c:4
#define WCTYPE_BLANK
Definition: wctype.h:19
int iswlower(wint_t)
Definition: iswlower.c:3
int iswspace(wint_t)
Definition: iswspace.c:8
int iswalpha(wint_t)
Definition: iswalpha.c:7

References iswalnum(), iswalpha(), iswblank(), iswcntrl(), iswdigit(), iswgraph(), iswlower(), iswprint(), iswpunct(), iswspace(), iswupper(), iswxdigit(), WCTYPE_ALNUM, WCTYPE_ALPHA, WCTYPE_BLANK, WCTYPE_CNTRL, WCTYPE_DIGIT, WCTYPE_GRAPH, WCTYPE_LOWER, WCTYPE_PRINT, WCTYPE_PUNCT, WCTYPE_SPACE, WCTYPE_UPPER, and WCTYPE_XDIGIT.

◆ iswdigit()

int iswdigit ( wint_t  )

Definition at line 3 of file iswdigit.c.

4 {
5  return (unsigned)wc - '0' < 10;
6 }

Referenced by iswalnum(), and iswctype().

Here is the caller graph for this function:

◆ iswgraph()

int iswgraph ( wint_t  )

Definition at line 3 of file iswgraph.c.

4 {
5  /* ISO C defines this function as: */
6  return !iswspace(wc) && iswprint(wc);
7 }
int iswprint(wint_t)
Definition: iswprint.c:10
int iswspace(wint_t)
Definition: iswspace.c:8

References iswprint(), and iswspace().

Referenced by iswctype().

Here is the caller graph for this function:

◆ iswlower()

int iswlower ( wint_t  )

Definition at line 3 of file iswlower.c.

4 {
5  return towupper(wc) != wc;
6 }
wint_t towupper(wint_t)
Definition: towupper.c:4

References towupper().

Referenced by iswctype().

Here is the caller graph for this function:

◆ iswprint()

int iswprint ( wint_t  )

Definition at line 10 of file iswprint.c.

11 {
12  if(wc < 0xffU)
13  {
14  return (wc + 1 & 0x7f) >= 0x21;
15  }
16  if(wc < 0x2028U || wc - 0x202aU < 0xd800 - 0x202a || wc - 0xe000U < 0xfff9 - 0xe000)
17  {
18  return 1;
19  }
20  if(wc - 0xfffcU > 0x10ffff - 0xfffc || (wc & 0xfffe) == 0xfffe)
21  {
22  return 0;
23  }
24 
25  return 1;
26 }

Referenced by iswctype(), and iswgraph().

Here is the caller graph for this function:

◆ iswpunct()

int iswpunct ( wint_t  )

Definition at line 7 of file iswpunct.c.

8 {
9  if(wc < 0x20000U)
10  {
11  return (table[table[wc >> 8] * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1;
12  }
13  return 0;
14 }
static const unsigned char table[]
Definition: iswpunct.c:3

References table.

Referenced by iswctype().

Here is the caller graph for this function:

◆ iswspace()

int iswspace ( wint_t  )

Definition at line 8 of file iswspace.c.

9 {
10  static const wchar_t spaces[] = {' ', '\t', '\n', '\r', 11, 12, 0x0085, 0x2000,
11  0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2008, 0x2009,
12  0x200a, 0x2028, 0x2029, 0x205f, 0x3000, 0};
13  return wc && wcschr(spaces, (wchar_t)wc);
14 }
wchar_t * wcschr(const wchar_t *, wchar_t)

References wcschr().

Referenced by iswctype(), and iswgraph().

Here is the caller graph for this function:

◆ iswupper()

int iswupper ( wint_t  )

Definition at line 3 of file iswupper.c.

4 {
5  return towlower(wc) != wc;
6 }
wint_t towlower(wint_t)
Definition: towlower.c:4

References towlower().

Referenced by iswctype().

Here is the caller graph for this function:

◆ iswxdigit()

int iswxdigit ( wint_t  )

Definition at line 3 of file iswxdigit.c.

4 {
5  return (unsigned)(wc - '0') < 10 || (unsigned)((wc | 32) - 'a') < 6;
6 }

Referenced by iswctype().

Here is the caller graph for this function:

◆ towctrans()

wint_t towctrans ( wint_t  ,
wctrans_t   
)

Definition at line 4 of file towctrans.c.

5 {
6  if(trans == (wctrans_t)1)
7  {
8  return towupper(wc);
9  }
10 
11  if(trans == (wctrans_t)2)
12  {
13  return towlower(wc);
14  }
15 
16  return wc;
17 }
wint_t towlower(wint_t)
Definition: towlower.c:4
wint_t towupper(wint_t)
Definition: towupper.c:4
const int * wctrans_t
Definition: wctype.h:10

References towlower(), and towupper().

◆ towlower()

wint_t towlower ( wint_t  )

Definition at line 4 of file towlower.c.

5 {
6  return (wint_t)(wc < 128 ? tolower((int)wc) : __towcase((wchar_t)wc, 1));
7 }
int tolower(int ch)
Converts the given character to lowercase.
Definition: tolower.c:5
unsigned wint_t
Definition: wctype.h:11
wchar_t __towcase(wchar_t wc, int lower)
Definition: towccase.c:218

References __towcase(), and tolower().

Referenced by iswupper(), and towctrans().

Here is the caller graph for this function:

◆ towupper()

wint_t towupper ( wint_t  )

Definition at line 4 of file towupper.c.

5 {
6  return (wint_t)(wc < 128 ? toupper((int)wc) : __towcase((wchar_t)wc, 0));
7 }
unsigned wint_t
Definition: wctype.h:11
int toupper(int ch)
Converts the given character to lowercase.
Definition: toupper.c:5
wchar_t __towcase(wchar_t wc, int lower)
Definition: towccase.c:218

References __towcase(), and toupper().

Referenced by iswlower(), and towctrans().

Here is the caller graph for this function:

◆ wctrans()

wctrans_t wctrans ( const char *  )

Definition at line 4 of file wctrans.c.

5 {
6  if(!strcmp(class, "toupper"))
7  {
8  return (wctrans_t)1;
9  }
10 
11  if(!strcmp(class, "tolower"))
12  {
13  return (wctrans_t)2;
14  }
15 
16  return 0;
17 }
int strcmp(const char *s1, const char *s2)
Compares two null-terminated byte strings lexicographically.
Definition: strcmp.c:12
const int * wctrans_t
Definition: wctype.h:10

References strcmp().

◆ wctype()

wctype_t wctype ( const char *  )

Definition at line 4 of file wctype.c.

5 {
6  wctype_t i;
7  const char* p;
8  /* order must match! */
9  static const char names[] = "alnum\0"
10  "alpha\0"
11  "blank\0"
12  "cntrl\0"
13  "digit\0"
14  "graph\0"
15  "lower\0"
16  "print\0"
17  "punct\0"
18  "space\0"
19  "upper\0"
20  "xdigit";
21  for(i = 1, p = names; *p; i++, p += 6)
22  {
23  if(*s == *p && !strcmp(s, p))
24  {
25  return i;
26  }
27  }
28  return 0;
29 }
int strcmp(const char *s1, const char *s2)
Compares two null-terminated byte strings lexicographically.
Definition: strcmp.c:12
unsigned long wctype_t
Definition: wctype.h:12

References strcmp().