Denys Vlasenko | 42a8fd0 | 2009-07-11 21:36:13 +0200 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * Licensed under the GPL version 2, see the file LICENSE in this tarball. |
| 4 | */ |
| 5 | #ifndef UNICODE_H |
| 6 | #define UNICODE_H 1 |
| 7 | |
| 8 | #if !ENABLE_FEATURE_ASSUME_UNICODE |
| 9 | |
Denys Vlasenko | fda8f57 | 2009-07-11 22:26:48 +0200 | [diff] [blame] | 10 | # define bb_mbstrlen(string) strlen(string) |
Denys Vlasenko | 42a8fd0 | 2009-07-11 21:36:13 +0200 | [diff] [blame] | 11 | # define check_unicode_in_env() ((void)0) |
| 12 | |
| 13 | #else |
| 14 | |
Denys Vlasenko | fda8f57 | 2009-07-11 22:26:48 +0200 | [diff] [blame] | 15 | size_t bb_mbstrlen(const char *string) FAST_FUNC; |
| 16 | |
Denys Vlasenko | 42a8fd0 | 2009-07-11 21:36:13 +0200 | [diff] [blame] | 17 | # if ENABLE_LOCALE_SUPPORT |
| 18 | |
| 19 | # include <wchar.h> |
| 20 | # include <wctype.h> |
| 21 | # define check_unicode_in_env() ((void)0) |
| 22 | |
| 23 | # else |
| 24 | |
Denys Vlasenko | fda8f57 | 2009-07-11 22:26:48 +0200 | [diff] [blame] | 25 | /* Crude "locale support" which knows only C and Unicode locales */ |
| 26 | |
Denys Vlasenko | 42a8fd0 | 2009-07-11 21:36:13 +0200 | [diff] [blame] | 27 | # if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV |
| 28 | # define check_unicode_in_env() ((void)0) |
| 29 | # else |
| 30 | void check_unicode_in_env(void) FAST_FUNC; |
| 31 | # endif |
| 32 | |
| 33 | # undef MB_CUR_MAX |
| 34 | # define MB_CUR_MAX 6 |
| 35 | |
| 36 | /* Prevent name collisions */ |
| 37 | # define wint_t bb_wint_t |
| 38 | # define mbstate_t bb_mbstate_t |
| 39 | # define mbstowcs bb_mbstowcs |
| 40 | # define wcstombs bb_wcstombs |
| 41 | # define wcrtomb bb_wcrtomb |
| 42 | # define iswspace bb_iswspace |
| 43 | # define iswalnum bb_iswalnum |
| 44 | # define iswpunct bb_iswpunct |
| 45 | |
| 46 | typedef int32_t wint_t; |
| 47 | typedef struct { |
| 48 | char bogus; |
| 49 | } mbstate_t; |
| 50 | |
| 51 | size_t mbstowcs(wchar_t *dest, const char *src, size_t n) FAST_FUNC; |
| 52 | size_t wcstombs(char *dest, const wchar_t *src, size_t n) FAST_FUNC; |
| 53 | size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps) FAST_FUNC; |
| 54 | int iswspace(wint_t wc) FAST_FUNC; |
| 55 | int iswalnum(wint_t wc) FAST_FUNC; |
| 56 | int iswpunct(wint_t wc) FAST_FUNC; |
| 57 | |
Denys Vlasenko | fda8f57 | 2009-07-11 22:26:48 +0200 | [diff] [blame] | 58 | # endif /* !LOCALE_SUPPORT */ |
Denys Vlasenko | 42a8fd0 | 2009-07-11 21:36:13 +0200 | [diff] [blame] | 59 | |
Denys Vlasenko | fda8f57 | 2009-07-11 22:26:48 +0200 | [diff] [blame] | 60 | #endif /* FEATURE_ASSUME_UNICODE */ |
Denys Vlasenko | 42a8fd0 | 2009-07-11 21:36:13 +0200 | [diff] [blame] | 61 | |
| 62 | #endif |