blob: e0061478de33e5f6ff1de20fff01bd75a9d0b86e [file] [log] [blame]
Denys Vlasenko42a8fd02009-07-11 21:36:13 +02001/* 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 Vlasenkofda8f572009-07-11 22:26:48 +020010# define bb_mbstrlen(string) strlen(string)
Denys Vlasenko42a8fd02009-07-11 21:36:13 +020011# define check_unicode_in_env() ((void)0)
12
13#else
14
Denys Vlasenkofda8f572009-07-11 22:26:48 +020015size_t bb_mbstrlen(const char *string) FAST_FUNC;
16
Denys Vlasenko42a8fd02009-07-11 21:36:13 +020017# 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 Vlasenkofda8f572009-07-11 22:26:48 +020025/* Crude "locale support" which knows only C and Unicode locales */
26
Denys Vlasenko42a8fd02009-07-11 21:36:13 +020027# if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
28# define check_unicode_in_env() ((void)0)
29# else
30void 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
46typedef int32_t wint_t;
47typedef struct {
48 char bogus;
49} mbstate_t;
50
51size_t mbstowcs(wchar_t *dest, const char *src, size_t n) FAST_FUNC;
52size_t wcstombs(char *dest, const wchar_t *src, size_t n) FAST_FUNC;
53size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps) FAST_FUNC;
54int iswspace(wint_t wc) FAST_FUNC;
55int iswalnum(wint_t wc) FAST_FUNC;
56int iswpunct(wint_t wc) FAST_FUNC;
57
Denys Vlasenkofda8f572009-07-11 22:26:48 +020058# endif /* !LOCALE_SUPPORT */
Denys Vlasenko42a8fd02009-07-11 21:36:13 +020059
Denys Vlasenkofda8f572009-07-11 22:26:48 +020060#endif /* FEATURE_ASSUME_UNICODE */
Denys Vlasenko42a8fd02009-07-11 21:36:13 +020061
62#endif