source: MondoRescue/branches/2.2.9/mindi-busybox/include/unicode.h@ 2725

Last change on this file since 2725 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
  • Property svn:eol-style set to native
File size: 3.4 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
31#else
32
33# if CONFIG_LAST_SUPPORTED_WCHAR < 126 || CONFIG_LAST_SUPPORTED_WCHAR >= 0x30000
34# undef CONFIG_LAST_SUPPORTED_WCHAR
35# define CONFIG_LAST_SUPPORTED_WCHAR 0x2ffff
36# endif
37
38# if CONFIG_LAST_SUPPORTED_WCHAR < 0x300
39# undef ENABLE_UNICODE_COMBINING_WCHARS
40# define ENABLE_UNICODE_COMBINING_WCHARS 0
41# endif
42
43# if CONFIG_LAST_SUPPORTED_WCHAR < 0x1100
44# undef ENABLE_UNICODE_WIDE_WCHARS
45# define ENABLE_UNICODE_WIDE_WCHARS 0
46# endif
47
48# if CONFIG_LAST_SUPPORTED_WCHAR < 0x590
49# undef ENABLE_UNICODE_BIDI_SUPPORT
50# define ENABLE_UNICODE_BIDI_SUPPORT 0
51# endif
52
53/* Number of unicode chars. Falls back to strlen() on invalid unicode */
54size_t FAST_FUNC unicode_strlen(const char *string);
55/* Width on terminal */
56size_t FAST_FUNC unicode_strwidth(const char *string);
57enum {
58 UNI_FLAG_PAD = (1 << 0),
59};
60//UNUSED: unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src);
61//UNUSED: char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char *src, unsigned width, int flags);
62char* FAST_FUNC unicode_conv_to_printable(uni_stat_t *stats, const char *src);
63char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth);
64char* FAST_FUNC unicode_conv_to_printable_fixedwidth(uni_stat_t *stats, const char *src, unsigned width);
65
66# if ENABLE_UNICODE_USING_LOCALE
67
68extern uint8_t unicode_status;
69void init_unicode(void) FAST_FUNC;
70
71# else
72
73/* Homegrown Unicode support. It knows only C and Unicode locales. */
74
75# if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
76# define unicode_status UNICODE_ON
77# define init_unicode() ((void)0)
78# else
79extern uint8_t unicode_status;
80void init_unicode(void) FAST_FUNC;
81# endif
82
83# undef MB_CUR_MAX
84# define MB_CUR_MAX 6
85
86/* Prevent name collisions */
87# define wint_t bb_wint_t
88# define mbstate_t bb_mbstate_t
89# define mbstowcs bb_mbstowcs
90# define wcstombs bb_wcstombs
91# define wcrtomb bb_wcrtomb
92# define iswspace bb_iswspace
93# define iswalnum bb_iswalnum
94# define iswpunct bb_iswpunct
95# define wcwidth bb_wcwidth
96
97typedef int32_t wint_t;
98typedef struct {
99 char bogus;
100} mbstate_t;
101
102size_t mbstowcs(wchar_t *dest, const char *src, size_t n) FAST_FUNC;
103size_t wcstombs(char *dest, const wchar_t *src, size_t n) FAST_FUNC;
104size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps) FAST_FUNC;
105int iswspace(wint_t wc) FAST_FUNC;
106int iswalnum(wint_t wc) FAST_FUNC;
107int iswpunct(wint_t wc) FAST_FUNC;
108int wcwidth(unsigned ucs) FAST_FUNC;
109# if ENABLE_UNICODE_BIDI_SUPPORT
110# undef unicode_bidi_isrtl
111int unicode_bidi_isrtl(wint_t wc) FAST_FUNC;
112# if ENABLE_UNICODE_NEUTRAL_TABLE
113# undef unicode_bidi_is_neutral_wchar
114int unicode_bidi_is_neutral_wchar(wint_t wc) FAST_FUNC;
115# endif
116# endif
117
118
119# endif /* !UNICODE_USING_LOCALE */
120
121#endif /* UNICODE_SUPPORT */
122
123POP_SAVED_FUNCTION_VISIBILITY
124
125#endif
Note: See TracBrowser for help on using the repository browser.