xref: /haiku/headers/posix/wchar.h (revision 90dca2bc8ea3f248a1fe87fda98bc7f822dfcd38)
1e48a877cSbeveloper /*
2173f54f1SMatt Madia  * Copyright 2008-2012 Haiku, Inc. All Rights Reserved.
31d19f96fSMarcus Overhagen  * Distributed under the terms of the MIT License.
4e48a877cSbeveloper  */
50cb1c46aSshatty #ifndef _WCHAR_H
60cb1c46aSshatty #define _WCHAR_H
7e48a877cSbeveloper 
8c73ea821SAxel Dörfler 
9fa02fc69SOliver Tappe #include <limits.h>
10c95c1876SJérôme Duval #include <locale_t.h>
11404a0feaSIngo Weinhold #include <stddef.h>
12e589b330SAxel Dörfler #include <stdio.h>
13a5f30beaSPuck Meerburg #include <time.h>
140cb1c46aSshatty 
15c73ea821SAxel Dörfler 
16b9320128SIngo Weinhold /* stddef.h is not supposed to define wint_t, but gcc 2.95.3's one does.
17b9320128SIngo Weinhold  * In all other cases we will do that. */
18404a0feaSIngo Weinhold #ifndef _WINT_T
19abd010bcSJérôme Duval #define _WINT_T
20404a0feaSIngo Weinhold 
21404a0feaSIngo Weinhold #ifndef __WINT_TYPE__
22404a0feaSIngo Weinhold #define __WINT_TYPE__ unsigned int
23404a0feaSIngo Weinhold #endif
24404a0feaSIngo Weinhold 
25404a0feaSIngo Weinhold typedef __WINT_TYPE__ wint_t;
26404a0feaSIngo Weinhold 
27b9320128SIngo Weinhold #endif	/* _WINT_T */
28404a0feaSIngo Weinhold 
29a34963f3SJérôme Duval typedef int wctype_t;
30abd010bcSJérôme Duval 
31abd010bcSJérôme Duval typedef struct {
32ec99f3b2SOliver Tappe 	void* converter;
33ec99f3b2SOliver Tappe 	char charset[64];
34fa02fc69SOliver Tappe 	unsigned int count;
3563fe8ecdSIthamar R. Adema 	char data[1024 + 8];	/* 1024 bytes for data, 8 for alignment space */
36abd010bcSJérôme Duval } mbstate_t;
37abd010bcSJérôme Duval 
380cb1c46aSshatty 
39510c100aSOliver Tappe #define WEOF		((wint_t)(-1))
40510c100aSOliver Tappe 
41510c100aSOliver Tappe #define WCHAR_MIN	0x00000000UL
42510c100aSOliver Tappe #define WCHAR_MAX	0x7FFFFFFFUL
43510c100aSOliver Tappe 
44a3f66598SOliver Tappe /*
45a3f66598SOliver Tappe  * Haiku is always using UTF32 in wchars, other encodings can be handled
46cfe553b3SOliver Tappe  * by converting to/from wchar by means of mbrtowc() or wcrtomb().
47a3f66598SOliver Tappe  */
48a3f66598SOliver Tappe 
49510c100aSOliver Tappe 
5030589be5SIngo Weinhold #ifdef __cplusplus
5130589be5SIngo Weinhold extern "C" {
5230589be5SIngo Weinhold #endif
5330589be5SIngo Weinhold 
54510c100aSOliver Tappe extern wint_t	btowc(int);
55510c100aSOliver Tappe 
56b7417fbeSOliver Tappe extern wint_t	fgetwc(FILE *stream);
57b7417fbeSOliver Tappe extern wchar_t	*fgetws(wchar_t *dest, int destLength, FILE *stream);
58b7417fbeSOliver Tappe extern wint_t	fputwc(wchar_t wc, FILE *stream);
59b7417fbeSOliver Tappe extern int		fputws(const wchar_t *wcs, FILE *stream);
60b7417fbeSOliver Tappe extern int		fwide(FILE *stream, int mode);
61b7417fbeSOliver Tappe extern int		fwprintf(FILE *stream, const wchar_t *format, ...);
62b7417fbeSOliver Tappe extern int		fwscanf(FILE *stream, const wchar_t *format, ...);
63b7417fbeSOliver Tappe extern wint_t	getwc(FILE *stream);
64a34963f3SJérôme Duval extern wint_t	getwchar(void);
65a34963f3SJérôme Duval 
66b7417fbeSOliver Tappe extern size_t 	mbrlen(const char *s, size_t n, mbstate_t *mbState);
67752527a8SOliver Tappe extern size_t 	mbrtowc(wchar_t *dest, const char *src, size_t srcLength,
68b7417fbeSOliver Tappe 					mbstate_t *mbState);
69b7417fbeSOliver Tappe extern int		mbsinit(const mbstate_t *mbState);
70b7417fbeSOliver Tappe extern size_t	mbsnrtowcs(wchar_t *dest, const char **src, size_t srcLength,
71b7417fbeSOliver Tappe 					size_t destLength, mbstate_t *mbState);
72b7417fbeSOliver Tappe extern size_t	mbsrtowcs(wchar_t *dest, const char **src, size_t destLength,
73b7417fbeSOliver Tappe 					mbstate_t *mbState);
74a34963f3SJérôme Duval 
75b7417fbeSOliver Tappe extern wint_t	putwc(wchar_t wc, FILE *stream);
76b7417fbeSOliver Tappe extern wint_t	putwchar(wchar_t wc);
77a34963f3SJérôme Duval 
78b7417fbeSOliver Tappe extern int		swprintf(wchar_t *dest, size_t destLength,
79b7417fbeSOliver Tappe 					const wchar_t *format, ...);
80b7417fbeSOliver Tappe extern int		swscanf(const wchar_t *wcs, const wchar_t *format, ...);
81a34963f3SJérôme Duval 
82b7417fbeSOliver Tappe extern wint_t	ungetwc(wint_t wc, FILE *stream);
83a34963f3SJérôme Duval 
84b7417fbeSOliver Tappe extern int		vfwprintf(FILE *stream, const wchar_t *format, va_list arg);
85b7417fbeSOliver Tappe extern int		vfwscanf(FILE *stream, const wchar_t *format, va_list arg);
86b7417fbeSOliver Tappe extern int		vswprintf(wchar_t *dest, size_t destLength,
87b7417fbeSOliver Tappe 					const wchar_t *format, va_list arg);
88b7417fbeSOliver Tappe extern int		vswscanf(const wchar_t *wcs, const wchar_t *format,
89b7417fbeSOliver Tappe 					va_list arg);
90b7417fbeSOliver Tappe extern int		vwprintf(const wchar_t *format, va_list arg);
91b7417fbeSOliver Tappe extern int		vwscanf(const wchar_t *format, va_list arg);
92510c100aSOliver Tappe 
93b7417fbeSOliver Tappe extern wchar_t	*wcpcpy(wchar_t *dest, const wchar_t *src);
94b7417fbeSOliver Tappe extern wchar_t	*wcpncpy(wchar_t *dest, const wchar_t *src, size_t srcLength);
95b7417fbeSOliver Tappe extern size_t   wcrtomb(char *dest, wchar_t wc, mbstate_t *mbState);
96b7417fbeSOliver Tappe extern int		wcscasecmp(const wchar_t *wcs1, const wchar_t *wcs2);
97d338200eSTrung Nguyen extern int		wcscasecmp_l(const wchar_t *wcs1, const wchar_t *wcs2, locale_t locale);
98b7417fbeSOliver Tappe extern wchar_t	*wcscat(wchar_t *dest, const wchar_t *src);
99b7417fbeSOliver Tappe extern wchar_t	*wcschr(const wchar_t *wcs, wchar_t wc);
100*90dca2bcSAugustin Cavalier #ifdef _DEFAULT_SOURCE
101b7417fbeSOliver Tappe extern wchar_t	*wcschrnul(const wchar_t *wcs, wchar_t wc);
102b7417fbeSOliver Tappe #endif
103b7417fbeSOliver Tappe extern int      wcscmp(const wchar_t *wcs1, const wchar_t *wcs2);
104b7417fbeSOliver Tappe extern int      wcscoll(const wchar_t *wcs1, const wchar_t *wcs2);
105d338200eSTrung Nguyen extern int		wcscoll_l(const wchar_t *wcs1, const wchar_t *wcs2, locale_t locale);
106b7417fbeSOliver Tappe extern wchar_t	*wcscpy(wchar_t *dest, const wchar_t *src);
107b7417fbeSOliver Tappe extern size_t	wcscspn(const wchar_t *wcs, const wchar_t *reject);
108b7417fbeSOliver Tappe extern wchar_t	*wcsdup(const wchar_t *wcs);
109b7417fbeSOliver Tappe extern size_t	wcsftime(wchar_t *dest, size_t destLength,
11076509315SAdrien Destugues 					const wchar_t *format, const struct tm *timeptr);
111b7417fbeSOliver Tappe extern size_t	wcslcat(wchar_t *dest, const wchar_t *src, size_t maxLength);
112b7417fbeSOliver Tappe extern size_t	wcslcpy(wchar_t *dest, const wchar_t *src, size_t maxLength);
113b7417fbeSOliver Tappe extern size_t	wcslen(const wchar_t *wcs);
114b7417fbeSOliver Tappe extern int		wcsncasecmp(const wchar_t *wcs1, const wchar_t *wcs2,
115b7417fbeSOliver Tappe 					size_t maxLength);
116d338200eSTrung Nguyen extern int		wcsncasecmp_l(const wchar_t *wcs1, const wchar_t *wcs2,
117d338200eSTrung Nguyen 					size_t maxLength, locale_t locale);
118b7417fbeSOliver Tappe extern wchar_t 	*wcsncat(wchar_t *dest, const wchar_t *src, size_t srcLength);
119b7417fbeSOliver Tappe extern int		wcsncmp(const wchar_t *wcs1, const wchar_t *wcs2,
120b7417fbeSOliver Tappe 					size_t length);
121b7417fbeSOliver Tappe extern wchar_t	*wcsncpy(wchar_t *dest, const wchar_t *src, size_t srcLength);
122b7417fbeSOliver Tappe extern size_t	wcsnlen(const wchar_t *wcs, size_t maxLength);
123b7417fbeSOliver Tappe extern size_t   wcsnrtombs(char *dest, const wchar_t **src, size_t srcLength,
124b7417fbeSOliver Tappe 					size_t destLength, mbstate_t *mbState);
125b7417fbeSOliver Tappe extern wchar_t	*wcspbrk(const wchar_t *wcs, const wchar_t *accept);
126b7417fbeSOliver Tappe extern wchar_t	*wcsrchr(const wchar_t *wcs, wchar_t wc);
127b7417fbeSOliver Tappe extern size_t   wcsrtombs(char *dest, const wchar_t **src, size_t destLength,
128b7417fbeSOliver Tappe 					mbstate_t *mbState);
129b7417fbeSOliver Tappe extern size_t	wcsspn(const wchar_t *wcs, const wchar_t *accept);
130b7417fbeSOliver Tappe extern wchar_t	*wcsstr(const wchar_t *haystack, const wchar_t *needle);
131b7417fbeSOliver Tappe extern double	wcstod(const wchar_t *wcs, wchar_t **endPtr);
132b7417fbeSOliver Tappe extern float	wcstof(const wchar_t *wcs, wchar_t **endPtr);
133b7417fbeSOliver Tappe extern wchar_t	*wcstok(wchar_t *wcs1, const wchar_t *wcs2, wchar_t **ptr);
134b7417fbeSOliver Tappe extern long		wcstol(const wchar_t *wcs, wchar_t **endPtr, int base);
135b7417fbeSOliver Tappe extern long double	wcstold(const wchar_t *wcs, wchar_t **endPtr);
136b7417fbeSOliver Tappe extern long long	wcstoll(const wchar_t *wcs, wchar_t **endPtr, int base);
137b7417fbeSOliver Tappe extern unsigned long	wcstoul(const wchar_t *wcs, wchar_t **endPtr,
138b7417fbeSOliver Tappe 							int base);
139b7417fbeSOliver Tappe extern unsigned long long	wcstoull(const wchar_t *wcs, wchar_t **endPtr,
140b7417fbeSOliver Tappe 								int base);
141b7417fbeSOliver Tappe extern wchar_t	*wcswcs(const wchar_t *haystack, const wchar_t *needle);
142b7417fbeSOliver Tappe extern int		wcswidth(const wchar_t *wcs, size_t length);
143b7417fbeSOliver Tappe extern size_t	wcsxfrm(wchar_t *dest, const wchar_t *src, size_t destLength);
144d338200eSTrung Nguyen extern size_t	wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t destLength,
145d338200eSTrung Nguyen 					locale_t locale);
146b7417fbeSOliver Tappe extern int		wctob(wint_t wc);
147b7417fbeSOliver Tappe extern int		wcwidth(wchar_t wc);
148b7417fbeSOliver Tappe extern wchar_t	*wmemchr(const wchar_t *wcs, wchar_t wc, size_t n);
149b7417fbeSOliver Tappe extern int		wmemcmp(const wchar_t *wcs1, const wchar_t *wcs2, size_t n);
150b7417fbeSOliver Tappe extern wchar_t	*wmemcpy(wchar_t *dest, const wchar_t *src, size_t n);
151b7417fbeSOliver Tappe extern wchar_t	*wmemmove(wchar_t *dest, const wchar_t *src, size_t n);
152*90dca2bcSAugustin Cavalier #ifdef _DEFAULT_SOURCE
153b7417fbeSOliver Tappe extern wchar_t	*wmempcpy(wchar_t *dest, const wchar_t *src, size_t n);
154b7417fbeSOliver Tappe #endif
155b7417fbeSOliver Tappe extern wchar_t	*wmemset(wchar_t *dest, wchar_t wc, size_t n);
156b7417fbeSOliver Tappe 
157b7417fbeSOliver Tappe extern int		wprintf(const wchar_t *format, ...);
158b7417fbeSOliver Tappe extern int		wscanf(const wchar_t *format, ...);
159e0f9a4e8SJérôme Duval 
16030589be5SIngo Weinhold #ifdef __cplusplus
16130589be5SIngo Weinhold }
16230589be5SIngo Weinhold #endif
16330589be5SIngo Weinhold 
1640cb1c46aSshatty #endif /* _WCHAR_H */
165