Back to index

courier  0.68.2
Classes | Defines | Typedefs | Functions | Variables
unicode.h File Reference
#include "../unicode/unicode_config.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>

Go to the source code of this file.

Classes

struct  unicode_buf

Defines

#define UNICODE_LB_MANDATORY   -1
#define UNICODE_LB_NONE   0
#define UNICODE_LB_ALLOWED   1
#define UNICODE_LB_OPT_PRBREAK   0x0001
#define UNICODE_LB_OPT_SYBREAK   0x0002
#define UNICODE_LB_OPT_DASHWJ   0x0004
#define unicode_buf_init_copy(a, b)
#define unicode_buf_ptr(p)   ((p)->ptr)
#define unicode_buf_len(p)   ((p)->len)
#define unicode_buf_clear(p)   ((p)->len=0)
#define unicode_buf_append_buf(a, b)   unicode_buf_append((a), unicode_buf_ptr(b), unicode_buf_len(b))
#define unicode_x_imap_modutf7   "x-imap-modutf7"

Typedefs

typedef uint32_t unicode_char
typedef struct unicode_lb_infounicode_lb_info_t
typedef struct unicode_lbc_infounicode_lbc_info_t
typedef struct unicode_wb_infounicode_wb_info_t
typedef struct
unicode_wbscan_info
unicode_wbscan_info_t
typedef struct
libmail_u_convert_hdr
libmail_u_convert_handle_t

Functions

const char * unicode_default_chset ()
unicode_char unicode_uc (unicode_char)
unicode_char unicode_lc (unicode_char)
unicode_char unicode_tc (unicode_char)
unicode_char unicode_html40ent_lookup (const char *n)
int unicode_wcwidth (unicode_char c)
size_t unicode_wcwidth_str (const unicode_char *c)
int unicode_isspace (unicode_char ch)
uint8_t unicode_tab_lookup (unicode_char ch, const size_t *unicode_indextab, size_t unicode_indextab_sizeof, const uint8_t(*unicode_rangetab)[2], const uint8_t *unicode_classtab, uint8_t uclass)
int unicode_grapheme_break (unicode_char a, unicode_char b)
unicode_lb_info_t unicode_lb_init (int(*cb_func)(int, void *), void *cb_arg)
int unicode_lb_next (unicode_lb_info_t i, unicode_char ch)
int unicode_lb_next_cnt (unicode_lb_info_t i, const unicode_char *chars, size_t cnt)
int unicode_lb_end (unicode_lb_info_t i)
unicode_lbc_info_t unicode_lbc_init (int(*cb_func)(int, unicode_char, void *), void *cb_arg)
int unicode_lbc_next (unicode_lbc_info_t i, unicode_char ch)
int unicode_lbc_end (unicode_lbc_info_t i)
void unicode_lb_set_opts (unicode_lb_info_t i, int opts)
void unicode_lbc_set_opts (unicode_lbc_info_t i, int opts)
unicode_wb_info_t unicode_wb_init (int(*cb_func)(int, void *), void *cb_arg)
int unicode_wb_next (unicode_wb_info_t i, unicode_char ch)
int unicode_wb_next_cnt (unicode_wb_info_t i, const unicode_char *chars, size_t cnt)
int unicode_wb_end (unicode_wb_info_t i)
unicode_wbscan_info_t unicode_wbscan_init ()
int unicode_wbscan_next (unicode_wbscan_info_t i, unicode_char ch)
size_t unicode_wbscan_end (unicode_wbscan_info_t i)
void unicode_buf_init (struct unicode_buf *p, size_t max)
void unicode_buf_deinit (struct unicode_buf *p)
int unicode_buf_append (struct unicode_buf *p, const unicode_char *uc, size_t l)
void unicode_buf_append_char (struct unicode_buf *dst, const char *str, size_t cnt)
void unicode_buf_remove (struct unicode_buf *p, size_t pos, size_t cnt)
int unicode_buf_cmp (const struct unicode_buf *a, const struct unicode_buf *b)
int unicode_buf_cmp_str (const struct unicode_buf *p, const char *c, size_t cl)
libmail_u_convert_handle_t libmail_u_convert_init (const char *src_chset, const char *dst_chset, int(*output_func)(const char *, size_t, void *), void *convert_arg)
int libmail_u_convert (libmail_u_convert_handle_t handle, const char *text, size_t cnt)
int libmail_u_convert_deinit (libmail_u_convert_handle_t handle, int *errptr)
libmail_u_convert_handle_t libmail_u_convert_tocbuf_init (const char *src_chset, const char *dst_chset, char **cbufptr_ret, size_t *cbufsize_ret, int nullterminate)
libmail_u_convert_handle_t libmail_u_convert_tou_init (const char *src_chset, unicode_char **ucptr_ret, size_t *ucsize_ret, int nullterminate)
libmail_u_convert_handle_t libmail_u_convert_fromu_init (const char *dst_chset, char **cbufptr_ret, size_t *cbufsize_ret, int nullterminate)
int libmail_u_convert_uc (libmail_u_convert_handle_t handle, const unicode_char *text, size_t cnt)
libmail_u_convert_handle_t libmail_u_convert_tocbuf_toutf8_init (const char *src_chset, char **cbufptr_ret, size_t *cbufsize_ret, int nullterminate)
libmail_u_convert_handle_t libmail_u_convert_tocbuf_fromutf8_init (const char *dst_chset, char **cbufptr_ret, size_t *cbufsize_ret, int nullterminate)
char * libmail_u_convert_toutf8 (const char *text, const char *charset, int *error)
char * libmail_u_convert_fromutf8 (const char *text, const char *charset, int *error)
char * libmail_u_convert_tobuf (const char *text, const char *charset, const char *dstcharset, int *error)
int libmail_u_convert_tou_tobuf (const char *text, size_t text_l, const char *charset, unicode_char **uc, size_t *ucsize, int *err)
int libmail_u_convert_fromu_tobuf (const unicode_char *utext, size_t utext_l, const char *charset, char **c, size_t *csize, int *err)
char * libmail_u_convert_tocase (const char *str, const char *charset, unicode_char(*first_char_func)(unicode_char), unicode_char(*char_func)(unicode_char))

Variables

const char libmail_u_ucs4_native []
const char libmail_u_ucs2_native []

Class Documentation

struct unicode_buf

Definition at line 365 of file unicode.h.

Class Members
size_t len
size_t max
unicode_char * ptr
size_t size

Define Documentation

#define unicode_buf_append_buf (   a,
 
)    unicode_buf_append((a), unicode_buf_ptr(b), unicode_buf_len(b))

Definition at line 451 of file unicode.h.

#define unicode_buf_clear (   p)    ((p)->len=0)

Definition at line 417 of file unicode.h.

#define unicode_buf_init_copy (   a,
 
)
Value:
do {                                             \
              unicode_buf_init((a), unicode_buf_len(b));       \
              unicode_buf_append_buf((a),(b));          \
       } while (0)

Definition at line 391 of file unicode.h.

#define unicode_buf_len (   p)    ((p)->len)

Definition at line 411 of file unicode.h.

#define unicode_buf_ptr (   p)    ((p)->ptr)

Definition at line 406 of file unicode.h.

#define UNICODE_LB_ALLOWED   1

Definition at line 143 of file unicode.h.

#define UNICODE_LB_MANDATORY   -1

Definition at line 141 of file unicode.h.

#define UNICODE_LB_NONE   0

Definition at line 142 of file unicode.h.

#define UNICODE_LB_OPT_DASHWJ   0x0004

Definition at line 257 of file unicode.h.

#define UNICODE_LB_OPT_PRBREAK   0x0001

Definition at line 233 of file unicode.h.

#define UNICODE_LB_OPT_SYBREAK   0x0002

Definition at line 249 of file unicode.h.

#define unicode_x_imap_modutf7   "x-imap-modutf7"

Definition at line 880 of file unicode.h.


Typedef Documentation

Definition at line 497 of file unicode.h.

typedef uint32_t unicode_char

Definition at line 39 of file unicode.h.

Definition at line 147 of file unicode.h.

Definition at line 204 of file unicode.h.

Definition at line 290 of file unicode.h.

Definition at line 353 of file unicode.h.


Function Documentation

int libmail_u_convert ( libmail_u_convert_handle_t  handle,
const char *  text,
size_t  cnt 
)

Definition at line 718 of file unicode.c.

{
       return (*h->convert_handler)(h->ptr, text, cnt);
}

Here is the caller graph for this function:

int libmail_u_convert_deinit ( libmail_u_convert_handle_t  handle,
int *  errptr 
)

Definition at line 726 of file unicode.c.

{
       return (*h->deinit_handler)(h, errptr);
}

Here is the caller graph for this function:

libmail_u_convert_handle_t libmail_u_convert_fromu_init ( const char *  dst_chset,
char **  cbufptr_ret,
size_t *  cbufsize_ret,
int  nullterminate 
)

Definition at line 1386 of file unicode.c.

{
       return libmail_u_convert_tocbuf_init(libmail_u_ucs4_native,
                                        dst_chset,
                                        cbufptr_ret,
                                        csize_ret,
                                        nullterminate);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_u_convert_fromu_tobuf ( const unicode_char utext,
size_t  utext_l,
const char *  charset,
char **  c,
size_t *  csize,
int *  err 
)

Definition at line 1566 of file unicode.c.

{
       libmail_u_convert_handle_t h;

       if (utext_l == (size_t)-1)
       {
              for (utext_l=0; utext[utext_l]; ++utext_l)
                   ;
       }

       if ((h=libmail_u_convert_fromu_init(charset, c, csize, 1)) == NULL)
              return -1;

       if (libmail_u_convert_uc(h, utext, utext_l) < 0)
       {
              libmail_u_convert_deinit(h, NULL);
              return -1;
       }

       if (libmail_u_convert_deinit(h, err))
              return -1;

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* libmail_u_convert_fromutf8 ( const char *  text,
const char *  charset,
int *  error 
)

Definition at line 1270 of file unicode.c.

{
       char *cbufptr;
       size_t cbufsize;
       libmail_u_convert_handle_t h=
              libmail_u_convert_tocbuf_fromutf8_init(charset,
                                                 &cbufptr,
                                                 &cbufsize, 1);

       if (!h)
              return NULL;

       libmail_u_convert(h, text, strlen(text));

       if (libmail_u_convert_deinit(h, error) == 0)
              return cbufptr;

       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

libmail_u_convert_handle_t libmail_u_convert_init ( const char *  src_chset,
const char *  dst_chset,
int(*)(const char *, size_t, void *)  output_func,
void *  convert_arg 
)

Definition at line 262 of file unicode.c.

{
       struct libmail_u_convert_toimaputf7 *toutf7;
       libmail_u_convert_handle_t h;
       const char *smapmunge;
       size_t l=strlen(unicode_x_imap_modutf7);

       if (strncmp(dst_chset, unicode_x_imap_modutf7, l) == 0 &&
           (dst_chset[l] == 0 || dst_chset[l] == ' '))
       {
              smapmunge=dst_chset + l;

              if (*smapmunge)
                     ++smapmunge;
       }
       else
              return init_nottoimaputf7(src_chset, dst_chset,
                                        output_func,
                                        convert_arg);

       toutf7=malloc(sizeof(struct libmail_u_convert_toimaputf7));

       if (!toutf7)
              return NULL;

       memset(toutf7, 0, sizeof(*toutf7));

       h=init_nottoimaputf7(src_chset, libmail_u_ucs2_native,
                          do_convert_toutf7, toutf7);
       if (!h)
       {
              free(toutf7);
              return (NULL);
       }

       toutf7->output_func=output_func;
       toutf7->convert_arg=convert_arg;

       strncat(toutf7->smapmunge, smapmunge, sizeof(toutf7->smapmunge)-1);

       toutf7->hdr.convert_handler=convert_utf7_handler;
       toutf7->hdr.deinit_handler=deinit_toimaputf7;
       toutf7->hdr.ptr=toutf7;
       toutf7->hdr.next=h;
       return &toutf7->hdr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* libmail_u_convert_tobuf ( const char *  text,
const char *  charset,
const char *  dstcharset,
int *  error 
)

Definition at line 1292 of file unicode.c.

{
       char *cbufptr;
       size_t cbufsize;
       libmail_u_convert_handle_t h=
              libmail_u_convert_tocbuf_init(charset,
                                         dstcharset,
                                         &cbufptr,
                                         &cbufsize, 1);

       if (!h)
              return NULL;

       libmail_u_convert(h, text, strlen(text));

       if (libmail_u_convert_deinit(h, error) == 0)
              return cbufptr;

       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* libmail_u_convert_tocase ( const char *  str,
const char *  charset,
unicode_char(*)(unicode_char first_char_func,
unicode_char(*)(unicode_char char_func 
)

Definition at line 1596 of file unicode.c.

{
       unicode_char *uc;
       size_t ucsize;
       size_t i;
       int err;
       char *c;
       size_t csize;

       if (libmail_u_convert_tou_tobuf(str, strlen(str),
                                   charset, &uc, &ucsize, &err))
              return NULL;

       if (err)
       {
              free(uc);
              return NULL;
       }

       for (i=0; i<ucsize; ++i)
       {
              uc[i]=(*first_char_func)(uc[i]);

              if (char_func)
                     first_char_func=char_func;
       }

       if (libmail_u_convert_fromu_tobuf(uc, ucsize,
                                     charset,
                                     &c, &csize, &err))
       {
              free(uc);
              return NULL;
       }

       free(uc);

       if (err)
       {
              free(c);
              return NULL;
       }

       return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

libmail_u_convert_handle_t libmail_u_convert_tocbuf_fromutf8_init ( const char *  dst_chset,
char **  cbufptr_ret,
size_t *  cbufsize_ret,
int  nullterminate 
)

Definition at line 1237 of file unicode.c.

{
       return libmail_u_convert_tocbuf_init("utf-8", dst_chset,
                                        cbufptr_ret, cbufsize_ret,
                                        nullterminate);
}

Here is the call graph for this function:

Here is the caller graph for this function:

libmail_u_convert_handle_t libmail_u_convert_tocbuf_init ( const char *  src_chset,
const char *  dst_chset,
char **  cbufptr_ret,
size_t *  cbufsize_ret,
int  nullterminate 
)

Definition at line 1089 of file unicode.c.

{
       struct libmail_u_convert_tocbuf *p=
              malloc(sizeof(struct libmail_u_convert_tocbuf));
       libmail_u_convert_handle_t h;

       if (!p)
              return NULL;

       memset(p, 0, sizeof(*p));

       h=libmail_u_convert_init(src_chset, dst_chset, save_tocbuf, p);

       if (!h)
       {
              free(p);
              return NULL;
       }

       p->cbufptr_ret=cbufptr_ret;
       p->cbufsize_ret=cbufsize_ret;
       p->last= &p->first;
       p->nullterminate=nullterminate;
       p->hdr.next=h;
       p->hdr.convert_handler=convert_tocbuf;
       p->hdr.deinit_handler=deinit_tocbuf;
       p->hdr.ptr=p;
       return &p->hdr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

libmail_u_convert_handle_t libmail_u_convert_tocbuf_toutf8_init ( const char *  src_chset,
char **  cbufptr_ret,
size_t *  cbufsize_ret,
int  nullterminate 
)

Definition at line 1225 of file unicode.c.

Here is the call graph for this function:

Here is the caller graph for this function:

libmail_u_convert_handle_t libmail_u_convert_tou_init ( const char *  src_chset,
unicode_char **  ucptr_ret,
size_t *  ucsize_ret,
int  nullterminate 
)

Definition at line 1350 of file unicode.c.

{
       struct libmail_u_convert_tou *p=
              malloc(sizeof(struct libmail_u_convert_tou));
       libmail_u_convert_handle_t h;

       if (!p)
              return NULL;

       memset(p, 0, sizeof(*p));

       h=libmail_u_convert_init(src_chset, libmail_u_ucs4_native,
                             save_unicode, p);

       if (!h)
       {
              free(p);
              return NULL;
       }

       p->ucptr_ret=ucptr_ret;
       p->ucsize_ret=ucsize_ret;
       p->last= &p->first;
       p->nullterminate=nullterminate;
       p->hdr.next=h;
       p->hdr.convert_handler=convert_tounicode;
       p->hdr.deinit_handler=deinit_tounicode;
       p->hdr.ptr=p;
       return &p->hdr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_u_convert_tou_tobuf ( const char *  text,
size_t  text_l,
const char *  charset,
unicode_char **  uc,
size_t *  ucsize,
int *  err 
)

Definition at line 1542 of file unicode.c.

{
       libmail_u_convert_handle_t h;

       if ((h=libmail_u_convert_tou_init(charset, uc, ucsize, 0)) == NULL)
              return -1;

       if (libmail_u_convert(h, text, text_l) < 0)
       {
              libmail_u_convert_deinit(h, NULL);
              return -1;
       }

       if (libmail_u_convert_deinit(h, err))
              return -1;

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* libmail_u_convert_toutf8 ( const char *  text,
const char *  charset,
int *  error 
)

Definition at line 1248 of file unicode.c.

{
       char *cbufptr;
       size_t cbufsize;
       libmail_u_convert_handle_t h=
              libmail_u_convert_tocbuf_toutf8_init(charset,
                                               &cbufptr,
                                               &cbufsize, 1);

       if (!h)
              return NULL;

       libmail_u_convert(h, text, strlen(text));

       if (libmail_u_convert_deinit(h, error) == 0)
              return cbufptr;

       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_u_convert_uc ( libmail_u_convert_handle_t  handle,
const unicode_char text,
size_t  cnt 
)

Definition at line 1399 of file unicode.c.

{
       return libmail_u_convert(handle, (const char *)text,
                             cnt * sizeof(*text));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int unicode_buf_append ( struct unicode_buf p,
const unicode_char uc,
size_t  l 
)

Definition at line 26 of file unicodebuf.c.

{
       if (l > p->max-p->len)
              l=p->max-p->len;

       if (p->len + l > p->size)
       {
              size_t n=(p->len + l) * 2;
              unicode_char *newp;

              if (n < 256)
                     n=256;

              if (n > p->max)
                     n=p->max;

              newp=p->ptr ? realloc(p->ptr, n * sizeof(unicode_char))
                     : malloc(n * sizeof(unicode_char));

              if (!newp)
                     return -1;

              p->ptr=newp;
              p->size=n;
       }

       memcpy(p->ptr + p->len, uc, l * sizeof(unicode_char));

       p->len += l;
       return 0;
}

Here is the caller graph for this function:

void unicode_buf_append_char ( struct unicode_buf dst,
const char *  str,
size_t  cnt 
)

Definition at line 59 of file unicodebuf.c.

{
       unicode_char unicode_buf[256];

       while (cnt)
       {
              size_t n=sizeof(unicode_buf)/sizeof(unicode_buf[0]), i;

              if (n > cnt)
                     n=cnt;

              for (i=0; i<n; ++i)
                     unicode_buf[i]=(unsigned char)str[i];

              str += n;
              cnt -= n;
              unicode_buf_append(dst, unicode_buf, i);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int unicode_buf_cmp ( const struct unicode_buf a,
const struct unicode_buf b 
)

Definition at line 96 of file unicodebuf.c.

{
       size_t i;

       for (i=0; i<a->len && i<b->len; i++)
       {
              if (a->ptr[i] < b->ptr[i])
                     return -1;
              if (a->ptr[i] > b->ptr[i])
                     return 1;
       }

       return (a->len < b->len ? -1:a->len > b->len ? 1:0);
}

Here is the caller graph for this function:

int unicode_buf_cmp_str ( const struct unicode_buf p,
const char *  c,
size_t  cl 
)

Definition at line 112 of file unicodebuf.c.

{
       size_t i;

       for (i=0; i<p->len && i < cl; ++i)
       {
              if (p->ptr[i] < c[i])
                     return -1;

              if (p->ptr[i] > c[i])
                     return 1;
       }

       return (p->len < cl ? -1: p->len > cl ? 1:0);
}

Here is the caller graph for this function:

void unicode_buf_deinit ( struct unicode_buf p)

Definition at line 20 of file unicodebuf.c.

{
       if (p->ptr)
              free(p->ptr);
}

Here is the caller graph for this function:

void unicode_buf_init ( struct unicode_buf p,
size_t  max 
)

Definition at line 12 of file unicodebuf.c.

{
       p->ptr=0;
       p->size=0;
       p->len=0;
       p->max=max;
}

Here is the caller graph for this function:

void unicode_buf_remove ( struct unicode_buf p,
size_t  pos,
size_t  cnt 
)

Definition at line 81 of file unicodebuf.c.

{
       if (pos > p->len)
              pos=p->len;

       if (cnt > p->len-pos)
              cnt=p->len-pos;

       if (cnt)
              memmove(p->ptr+pos+cnt, p->ptr+pos, p->len-pos-cnt);
       p->len -= cnt;
}

Here is the caller graph for this function:

const char* unicode_default_chset ( )

Definition at line 110 of file unicode.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 28 of file unicode_graphemebreak.c.

{
       uint8_t ac=unicode_tab_lookup(a, unicode_indextab,
                      sizeof(unicode_indextab)/sizeof(unicode_indextab[0]),
                      unicode_rangetab,
                      unicode_classtab,
                      UNICODE_GRAPHEMEBREAK_ANY),
              bc=unicode_tab_lookup(b, unicode_indextab,
                      sizeof(unicode_indextab)/sizeof(unicode_indextab[0]),
                      unicode_rangetab,
                      unicode_classtab,
                      UNICODE_GRAPHEMEBREAK_ANY);

       /* GB1 and GB2 are implied */

       if (ac == UNICODE_GRAPHEMEBREAK_CR && bc == UNICODE_GRAPHEMEBREAK_LF)
              return 0; /* GB3 */


       switch (ac) {
       case UNICODE_GRAPHEMEBREAK_CR:
       case UNICODE_GRAPHEMEBREAK_LF:
       case UNICODE_GRAPHEMEBREAK_Control:
              return 1; /* GB4 */
       default:
              break;
       }

       switch (bc) {
       case UNICODE_GRAPHEMEBREAK_CR:
       case UNICODE_GRAPHEMEBREAK_LF:
       case UNICODE_GRAPHEMEBREAK_Control:
              return 1; /* GB5 */
       default:
              break;
       }

       if (ac == UNICODE_GRAPHEMEBREAK_L)
              switch (bc) {
              case UNICODE_GRAPHEMEBREAK_L:
              case UNICODE_GRAPHEMEBREAK_V:
              case UNICODE_GRAPHEMEBREAK_LV:
              case UNICODE_GRAPHEMEBREAK_LVT:
                     return 0; /* GB6 */
              }

       if ((ac == UNICODE_GRAPHEMEBREAK_LV ||
            ac == UNICODE_GRAPHEMEBREAK_V) &&
           (bc == UNICODE_GRAPHEMEBREAK_V ||
            bc == UNICODE_GRAPHEMEBREAK_T))
              return 0; /* GB7 */

       if ((ac == UNICODE_GRAPHEMEBREAK_LVT ||
            ac == UNICODE_GRAPHEMEBREAK_T) &&
           bc == UNICODE_GRAPHEMEBREAK_T)
              return 0; /* GB8 */

       if (bc == UNICODE_GRAPHEMEBREAK_Extend)
              return 0; /* GB9 */

       if (bc == UNICODE_GRAPHEMEBREAK_SpacingMark)
              return 0; /* GB9a */

       if (ac == UNICODE_GRAPHEMEBREAK_Prepend)
              return 0; /* GB9b */

       return 1; /* GB10 */
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 45 of file unicode_htmlent.c.

{
       const struct i *ptr=
              (const struct i *)bsearch(n, ii,
                                     sizeof(ii)/sizeof(ii[0]),
                                     sizeof(ii[0]), compar);

       if (ptr)
              return ptr->v;
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 45 of file unicode_wcwidth.c.

{
       if (ch == 9)
              return 1;

       switch (unicode_lb_lookup(ch)) {
       case UNICODE_LB_BK:
       case UNICODE_LB_CR:
       case UNICODE_LB_LF:
       case UNICODE_LB_NL:
       case UNICODE_LB_SP:
              return 1;
       }

       return 0;
}

Here is the call graph for this function:

Definition at line 70 of file unicode_linebreak.c.

{
       int rc=(*i->end_handler)(i);

       free(i);
       return rc;
}

Here is the caller graph for this function:

unicode_lb_info_t unicode_lb_init ( int(*)(int, void *)  cb_func,
void *  cb_arg 
)

Definition at line 58 of file unicode_linebreak.c.

{
       unicode_lb_info_t i=calloc(1, sizeof(struct unicode_lb_info));

       i->cb_func=cb_func;
       i->cb_arg=cb_arg;

       unicode_lb_reset(i);
       return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 120 of file unicode_linebreak.c.

{
       return (*i->next_handler)(i, (i->opts & UNICODE_LB_OPT_DASHWJ) &&
                              (ch == 0x2012 || ch == 0x2013)
                              ? UNICODE_LB_WJ:unicode_lb_lookup(ch));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int unicode_lb_next_cnt ( unicode_lb_info_t  i,
const unicode_char chars,
size_t  cnt 
)

Definition at line 92 of file unicode_linebreak.c.

{
       while (cnt)
       {
              int rc=unicode_lb_next(i, *chars);

              if (rc)
                     return rc;

              ++chars;
              --cnt;
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unicode_lb_set_opts ( unicode_lb_info_t  i,
int  opts 
)

Definition at line 78 of file unicode_linebreak.c.

{
       i->opts=opts;
}

Here is the caller graph for this function:

Definition at line 625 of file unicode_linebreak.c.

{
       int rc=unicode_lb_end(i->handle);

       unicode_buf_deinit(&i->buf);
       free(i);
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unicode_lbc_info_t unicode_lbc_init ( int(*)(int, unicode_char, void *)  cb_func,
void *  cb_arg 
)

Definition at line 587 of file unicode_linebreak.c.

{
       unicode_lbc_info_t h=
              (unicode_lbc_info_t)calloc(1, sizeof(struct unicode_lbc_info));

       if (!h)
              return NULL;

       h->cb_func=cb_func;
       h->cb_arg=cb_arg;

       if ((h->handle=unicode_lb_init(unicode_lbc_callback, h)) == NULL)
       {
              free(h);
              return NULL;
       }
       unicode_buf_init(&h->buf, (size_t)-1);
       return h;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 613 of file unicode_linebreak.c.

{
       if (i->buf_ptr >= unicode_buf_len(&i->buf))
       {
              i->buf_ptr=0;
              unicode_buf_clear(&i->buf);
       }

       unicode_buf_append(&i->buf, &ch, 1);
       return unicode_lb_next(i->handle, ch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unicode_lbc_set_opts ( unicode_lbc_info_t  i,
int  opts 
)

Definition at line 608 of file unicode_linebreak.c.

{
       unicode_lb_set_opts(i->handle, opts);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 41 of file unicode_ultcase.c.

{
       unsigned i=find_case(c);

       return (unicode_case_tab[i][0] != c ? c:unicode_case_tab[i][2]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t unicode_tab_lookup ( unicode_char  ch,
const size_t *  unicode_indextab,
size_t  unicode_indextab_sizeof,
const uint8_t(*)  unicode_rangetab[2],
const uint8_t *  unicode_classtab,
uint8_t  uclass 
)

Definition at line 12 of file unicode_tablookup.c.

{
       size_t cl=ch / BLOCK_SIZE;

       if (cl < unicode_indextab_sizeof-1)
       {
              const size_t start_pos=unicode_indextab[cl];
              const uint8_t (*p)[2]=unicode_rangetab + start_pos;
              size_t b=0, e=unicode_indextab[cl+1] - start_pos;
              uint8_t chmodcl= ch & (BLOCK_SIZE-1);

              while (b < e)
              {
                     size_t n=b + (e-b)/2;

                     if (chmodcl >= p[n][0])
                     {
                            if (chmodcl <= p[n][1])
                            {
                                   uclass=unicode_classtab[start_pos+n];
                                   break;
                            }
                            b=n+1;
                     }
                     else
                     {
                            e=n;
                     }
              }
       }

       return uclass;
}

Here is the caller graph for this function:

Definition at line 48 of file unicode_ultcase.c.

{
       unsigned i;
       unicode_char oc=c;

       c=unicode_lc(c);
       i=find_case(c);

       return (unicode_case_tab[i][0] != c ? oc:unicode_case_tab[i][3]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 34 of file unicode_ultcase.c.

{
       unsigned i=find_case(c);

       return (unicode_case_tab[i][0] != c ? c:unicode_case_tab[i][1]);
}

Here is the call graph for this function:

Definition at line 58 of file unicode_wordbreak.c.

{
       int rc;

       if (i->end_handler)
              rc=(*i->end_handler)(i);
       else
              rc=wb4(i);

       free(i);
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unicode_wb_info_t unicode_wb_init ( int(*)(int, void *)  cb_func,
void *  cb_arg 
)

Definition at line 44 of file unicode_wordbreak.c.

{
       unicode_wb_info_t i=calloc(1, sizeof(struct unicode_wb_info));

       if (!i)
              return NULL;

       i->next_handler=sot;
       i->cb_func=cb_func;
       i->cb_arg=cb_arg;
       return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 87 of file unicode_wordbreak.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int unicode_wb_next_cnt ( unicode_wb_info_t  i,
const unicode_char chars,
size_t  cnt 
)

Definition at line 71 of file unicode_wordbreak.c.

{
       int rc;

       while (cnt)
       {
              rc=unicode_wb_next(i, *chars++);
              --cnt;
              if (rc)
                     return rc;
       }
       return 0;
}

Here is the call graph for this function:

Definition at line 426 of file unicode_wordbreak.c.

{
       size_t n;

       unicode_wb_end(i->wb_handle);

       n=i->cnt;
       free(i);
       return n;
}

Here is the call graph for this function:

Definition at line 402 of file unicode_wordbreak.c.

{
       unicode_wbscan_info_t i=calloc(1, sizeof(struct unicode_wbscan_info));

       if (!i)
              return NULL;

       if ((i->wb_handle=unicode_wb_init(unicode_wbscan_callback, i)) == NULL)
       {
              free(i);
              return NULL;
       }

       return i;
}

Here is the call graph for this function:

Definition at line 418 of file unicode_wordbreak.c.

{
       if (!i->found)
              unicode_wb_next(i->wb_handle, ch);

       return i->found;
}

Here is the call graph for this function:

Definition at line 9 of file unicode_wcwidth.c.

{
       size_t b=0;
       size_t e=sizeof(unicode_wcwidth_tab)/sizeof(unicode_wcwidth_tab[0]);

       while (b < e)
       {
              size_t n=b + (e-b)/2;

              if (c >= unicode_wcwidth_tab[n][0])
              {
                     if (c <= unicode_wcwidth_tab[n][1])
                            return 2;
                     b=n+1;
              }
              else
              {
                     e=n;
              }
       }

       switch (unicode_lb_lookup(c)) {
       case UNICODE_LB_BK:
       case UNICODE_LB_CR:
       case UNICODE_LB_LF:
       case UNICODE_LB_CM:
       case UNICODE_LB_NL:
       case UNICODE_LB_WJ:
       case UNICODE_LB_ZW:
              return 0;
       default:
              break;
       }
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t unicode_wcwidth_str ( const unicode_char c)

Definition at line 62 of file unicode_wcwidth.c.

{
       size_t w=0;

       while (*c)
              w += unicode_wcwidth(*c++);


       return w;
}

Here is the call graph for this function:


Variable Documentation

const char libmail_u_ucs2_native[]

Definition at line 129 of file unicode.c.

const char libmail_u_ucs4_native[]

Definition at line 121 of file unicode.c.