Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
wcwidth.c File Reference
#include <wchar.h>
#include "nonspacing.h"
#include "wide.h"
Include dependency graph for wcwidth.c:

Go to the source code of this file.

Functions

int wcwidth (wchar_t wc)
 

Variables

static const unsigned char table []
 
static const unsigned char wtable []
 

Function Documentation

◆ wcwidth()

int wcwidth ( wchar_t  wc)

Definition at line 11 of file wcwidth.c.

12 {
13  if(wc < (wchar_t)0xffU)
14  {
15  return (wc + 1 & 0x7f) >= 0x21 ? 1 : wc ? -1 : 0;
16  }
17 
18  if((wc & (wchar_t)0xfffeffffU) < 0xfffe)
19  {
20  if((table[table[wc >> 8] * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1)
21  {
22  return 0;
23  }
24 
25  if((wtable[wtable[wc >> 8] * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1)
26  {
27  return 2;
28  }
29 
30  return 1;
31  }
32 
33  if((wc & 0xfffe) == 0xfffe)
34  {
35  return -1;
36  }
37 
38  if(wc - (wchar_t)0x20000U < 0x20000)
39  {
40  return 2;
41  }
42 
43  if(wc == 0xe0001 || wc - (wchar_t)0xe0020U < 0x5f || wc - 0xe0100 < 0xef)
44  {
45  return 0;
46  }
47 
48  return 1;
49 }
static const unsigned char wtable[]
Definition: wcwidth.c:7
static const unsigned char table[]
Definition: wcwidth.c:3

References table, and wtable.

Referenced by wcswidth().

Here is the caller graph for this function:

Variable Documentation

◆ table

const unsigned char table[]
static

Definition at line 3 of file wcwidth.c.

Referenced by wcwidth().

◆ wtable

const unsigned char wtable[]
static

Definition at line 7 of file wcwidth.c.

Referenced by wcwidth().