include/utf8.h
changeset 89 c190335dbab3
parent 88 9b5c2357fad7
child 90 3102f7def87b
equal deleted inserted replaced
88:9b5c2357fad7 89:c190335dbab3
     1 #ifndef __UTF8_H__
       
     2 #define __UTF8_H__ 1
       
     3 
       
     4 #include <config.h>
       
     5 
       
     6 #if defined HAVE_UNICODE && defined HAVE_WCHAR_H && defined HAVE_WCTYPE_H
       
     7 # define UNICODE
       
     8 #endif
       
     9 
       
    10 #ifdef HAVE_WCHAR_H
       
    11 # include <wchar.h>
       
    12 # define get_char_width(c) (utf8_mode ? wcwidth(get_char(c)) : 1)
       
    13 #else
       
    14 # define wcwidth(c) 1
       
    15 # define get_char_width(c) 1
       
    16 #endif
       
    17 
       
    18 #ifdef HAVE_WCTYPE_H
       
    19 # include <wctype.h>
       
    20 
       
    21 /* The following bit is a hack for Solaris 8&9 systems that don't have
       
    22  * iswblank().
       
    23  * For now i made sure it comes after wctype.h so it doesn't create
       
    24  * problems (wctype.h has calls to iswblank() before wctype() is declared).
       
    25  * (Sebastian Kayser)
       
    26  */
       
    27 # ifndef HAVE_ISWBLANK
       
    28 #  define iswblank(wc) iswctype(wc, wctype("blank"))
       
    29 # endif
       
    30 
       
    31 #else
       
    32 # define iswblank(c) (c == ' ')
       
    33 # define iswalnum(c) isalnum(c)
       
    34 # define iswprint(c) isprint(c)
       
    35 # define towupper(c) toupper(c)
       
    36 # define towlower(c) tolower(c)
       
    37 # define iswalpha(c) isalpha(c)
       
    38 #endif
       
    39 
       
    40 extern int utf8_mode;
       
    41 
       
    42 char *prev_char(char *str, const char *limit);
       
    43 char *next_char(char *str);
       
    44 unsigned get_char(const char *str);
       
    45 char *put_char(char *str, unsigned c);
       
    46 
       
    47 #endif /* __UTF8_H__ */
       
    48 
       
    49 /* vim: set expandtab cindent cinoptions=>2\:2(0:  For Vim users... */