aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/unicode.h31
1 files changed, 7 insertions, 24 deletions
diff --git a/include/unicode.h b/include/unicode.h
index e11f2f9da..f1a252cc7 100644
--- a/include/unicode.h
+++ b/include/unicode.h
@@ -13,13 +13,16 @@ enum {
13 13
14#if !ENABLE_FEATURE_ASSUME_UNICODE 14#if !ENABLE_FEATURE_ASSUME_UNICODE
15 15
16# define bb_mbstrlen(string) strlen(string) 16# define unicode_strlen(string) strlen(string)
17# define unicode_scrlen(string) TODO
17# define unicode_status UNICODE_OFF 18# define unicode_status UNICODE_OFF
18# define init_unicode() ((void)0) 19# define init_unicode() ((void)0)
19 20
20#else 21#else
21 22
22size_t bb_mbstrlen(const char *string) FAST_FUNC; 23size_t FAST_FUNC unicode_strlen(const char *string);
24char* FAST_FUNC unicode_cut_nchars(unsigned width, const char *src);
25unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src);
23 26
24# if ENABLE_LOCALE_SUPPORT 27# if ENABLE_LOCALE_SUPPORT
25 28
@@ -30,7 +33,7 @@ void init_unicode(void) FAST_FUNC;
30 33
31# else 34# else
32 35
33/* Crude "locale support" which knows only C and Unicode locales */ 36/* Homegrown Unicode support. It knows only C and Unicode locales. */
34 37
35# if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV 38# if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
36# define unicode_status UNICODE_ON 39# define unicode_status UNICODE_ON
@@ -52,6 +55,7 @@ void init_unicode(void) FAST_FUNC;
52# define iswspace bb_iswspace 55# define iswspace bb_iswspace
53# define iswalnum bb_iswalnum 56# define iswalnum bb_iswalnum
54# define iswpunct bb_iswpunct 57# define iswpunct bb_iswpunct
58# define wcwidth bb_wcwidth
55 59
56typedef int32_t wint_t; 60typedef int32_t wint_t;
57typedef struct { 61typedef struct {
@@ -68,27 +72,6 @@ int iswpunct(wint_t wc) FAST_FUNC;
68 72
69# endif /* !LOCALE_SUPPORT */ 73# endif /* !LOCALE_SUPPORT */
70 74
71
72# if 0 /* TODO: better support for printfing Unicode fields: */
73
74/* equivalent to printf("%-20.20s", str) */
75char unicode_buffer[20 * MB_CUR_MAX];
76printf("%s", unicode_exact(20, str, unicode_buffer);
77/* no need to free() anything */
78
79/* equivalent to printf("%-20s", str) */
80char *malloced = unicode_minimum(20, str);
81printf("%s", malloced);
82free(malloced); /* ugh */
83
84/* equivalent to printf("%-20s", str), better one */
85printf("%s%*s", str, unicode_pad_to_width(str, 20), "");
86/* equivalent to printf("%20s", str) */
87printf("%*s%s", unicode_pad_to_width(str, 20), "", str);
88
89# endif
90
91
92#endif /* FEATURE_ASSUME_UNICODE */ 75#endif /* FEATURE_ASSUME_UNICODE */
93 76
94#endif 77#endif