source: branches/3.2/mindi-busybox/include/unicode.h @ 3232

Last change on this file since 3232 was 3232, checked in by bruno, 6 years ago
  • Update mindi-busybox to 1.21.1
  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * Licensed under GPLv2, see file LICENSE in this source tree.
4 */
5#ifndef UNICODE_H
6#define UNICODE_H 1
7
8#if ENABLE_UNICODE_USING_LOCALE
9# include <wchar.h>
10# include <wctype.h>
11#endif
12
13PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
14
15enum {
16    UNICODE_UNKNOWN = 0,
17    UNICODE_OFF = 1,
18    UNICODE_ON = 2,
19};
20
21#define unicode_bidi_isrtl(wc) 0
22#define unicode_bidi_is_neutral_wchar(wc) (wc <= 126 && !isalpha(wc))
23
24#if !ENABLE_UNICODE_SUPPORT
25
26# define unicode_strlen(string)   strlen(string)
27# define unicode_strwidth(string) strlen(string)
28# define unicode_status UNICODE_OFF
29# define init_unicode() ((void)0)
30# define reinit_unicode(LANG) ((void)0)
31
32#else
33
34# if CONFIG_LAST_SUPPORTED_WCHAR < 126 || CONFIG_LAST_SUPPORTED_WCHAR >= 0x30000
35#  undef CONFIG_LAST_SUPPORTED_WCHAR
36#  define CONFIG_LAST_SUPPORTED_WCHAR 0x2ffff
37# endif
38
39# if CONFIG_LAST_SUPPORTED_WCHAR < 0x300
40#  undef ENABLE_UNICODE_COMBINING_WCHARS
41#  define ENABLE_UNICODE_COMBINING_WCHARS 0
42# endif
43
44# if CONFIG_LAST_SUPPORTED_WCHAR < 0x1100
45#  undef ENABLE_UNICODE_WIDE_WCHARS
46#  define ENABLE_UNICODE_WIDE_WCHARS 0
47# endif
48
49# if CONFIG_LAST_SUPPORTED_WCHAR < 0x590
50#  undef  ENABLE_UNICODE_BIDI_SUPPORT
51#  define ENABLE_UNICODE_BIDI_SUPPORT 0
52# endif
53
54/* Number of unicode chars. Falls back to strlen() on invalid unicode */
55size_t FAST_FUNC unicode_strlen(const char *string);
56/* Width on terminal */
57size_t FAST_FUNC unicode_strwidth(const char *string);
58enum {
59    UNI_FLAG_PAD = (1 << 0),
60};
61//UNUSED: unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src);
62//UNUSED: char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char *src, unsigned width, int flags);
63char* FAST_FUNC unicode_conv_to_printable(uni_stat_t *stats, const char *src);
64//UNUSED: char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth);
65char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ const char *src, unsigned width);
66
67# if ENABLE_UNICODE_USING_LOCALE
68
69extern uint8_t unicode_status;
70void init_unicode(void) FAST_FUNC;
71void reinit_unicode(const char *LANG) FAST_FUNC;
72
73# else
74
75/* Homegrown Unicode support. It knows only C and Unicode locales. */
76
77#  if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
78#   define unicode_status UNICODE_ON
79#   define init_unicode() ((void)0)
80#   define reinit_unicode(LANG) ((void)0)
81#  else
82extern uint8_t unicode_status;
83void init_unicode(void) FAST_FUNC;
84void reinit_unicode(const char *LANG) FAST_FUNC;
85#  endif
86
87#  undef MB_CUR_MAX
88#  define MB_CUR_MAX 6
89
90/* Prevent name collisions */
91#  define wint_t    bb_wint_t
92#  define mbstate_t bb_mbstate_t
93#  define mbstowcs  bb_mbstowcs
94#  define wcstombs  bb_wcstombs
95#  define wcrtomb   bb_wcrtomb
96#  define iswspace  bb_iswspace
97#  define iswalnum  bb_iswalnum
98#  define iswpunct  bb_iswpunct
99#  define wcwidth   bb_wcwidth
100
101typedef int32_t wint_t;
102typedef struct {
103    char bogus;
104} mbstate_t;
105
106size_t mbstowcs(wchar_t *dest, const char *src, size_t n) FAST_FUNC;
107size_t wcstombs(char *dest, const wchar_t *src, size_t n) FAST_FUNC;
108size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps) FAST_FUNC;
109int iswspace(wint_t wc) FAST_FUNC;
110int iswalnum(wint_t wc) FAST_FUNC;
111int iswpunct(wint_t wc) FAST_FUNC;
112int wcwidth(unsigned ucs) FAST_FUNC;
113#  if ENABLE_UNICODE_BIDI_SUPPORT
114#   undef unicode_bidi_isrtl
115int unicode_bidi_isrtl(wint_t wc) FAST_FUNC;
116#   if ENABLE_UNICODE_NEUTRAL_TABLE
117#    undef unicode_bidi_is_neutral_wchar
118int unicode_bidi_is_neutral_wchar(wint_t wc) FAST_FUNC;
119#   endif
120#  endif
121
122
123# endif /* !UNICODE_USING_LOCALE */
124
125#endif /* UNICODE_SUPPORT */
126
127POP_SAVED_FUNCTION_VISIBILITY
128
129#endif
Note: See TracBrowser for help on using the repository browser.