5 #include "utils/pg_locale.h"
6 #include "mb/pg_wchar.h"
12 * towlower() and friends should be in <wctype.h>, but some pre-C99 systems
13 * declare them in <wchar.h>.
22 #if defined(HAVE_WCSTOMBS) && defined(HAVE_TOWLOWER)
27 #endif /* TS_USE_WIDE */
30 #define TOUCHAR(x) (*((unsigned char*)(x)))
33 size_t char2wchar(wchar_t *to, const char *from, size_t len);
37 size_t wchar2char(char *to, const wchar_t *from, size_t len);
41 /* correct wcstombs */
42 #define wchar2char wcstombs
46 #define t_isdigit(x) ( pg_mblen(x)==1 && isdigit( TOUCHAR(x) ) )
47 #define t_isspace(x) ( pg_mblen(x)==1 && isspace( TOUCHAR(x) ) )
48 extern int _t_isalpha(const char *ptr);
50 #define t_isalpha(x) ( (pg_mblen(x)==1) ? isalpha( TOUCHAR(x) ) : _t_isalpha(x) )
51 extern int _t_isprint(const char *ptr);
53 #define t_isprint(x) ( (pg_mblen(x)==1) ? isprint( TOUCHAR(x) ) : _t_isprint(x) )
55 * t_iseq() should be called only for ASCII symbols
57 #define t_iseq(x,c) ( (pg_mblen(x)==1) ? ( TOUCHAR(x) == ((unsigned char)(c)) ) : false )
59 #define COPYCHAR(d,s) do { \
60 int lll = pg_mblen( s ); \
63 TOUCHAR((d)+lll) = TOUCHAR((s)+lll); \
66 #else /* not def TS_USE_WIDE */
68 #define t_isdigit(x) isdigit( TOUCHAR(x) )
69 #define t_isspace(x) isspace( TOUCHAR(x) )
70 #define t_isalpha(x) isalpha( TOUCHAR(x) )
71 #define t_isprint(x) isprint( TOUCHAR(x) )
72 #define t_iseq(x,c) ( TOUCHAR(x) == ((unsigned char)(c)) )
74 #define COPYCHAR(d,s) TOUCHAR(d) = TOUCHAR(s)
77 char *lowerstr(char *str);
79 #endif /* __TSLOCALE_H__ */