xref: /haiku/headers/posix/wchar.h (revision 63fe8ecdd98f53cc8710746ec9343a9b08838594)
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>
10404a0feaSIngo Weinhold #include <stddef.h>
11e589b330SAxel Dörfler #include <stdio.h>
120cb1c46aSshatty 
13c73ea821SAxel Dörfler 
14b9320128SIngo Weinhold /* stddef.h is not supposed to define wint_t, but gcc 2.95.3's one does.
15b9320128SIngo Weinhold  * In all other cases we will do that. */
16404a0feaSIngo Weinhold #ifndef _WINT_T
17abd010bcSJérôme Duval #define _WINT_T
18404a0feaSIngo Weinhold 
19404a0feaSIngo Weinhold #ifndef __WINT_TYPE__
20404a0feaSIngo Weinhold #define __WINT_TYPE__ unsigned int
21404a0feaSIngo Weinhold #endif
22404a0feaSIngo Weinhold 
23404a0feaSIngo Weinhold typedef __WINT_TYPE__ wint_t;
24404a0feaSIngo Weinhold 
25b9320128SIngo Weinhold #endif	/* _WINT_T */
26404a0feaSIngo Weinhold 
27a34963f3SJérôme Duval typedef int wctype_t;
28abd010bcSJérôme Duval 
29abd010bcSJérôme Duval typedef struct {
30ec99f3b2SOliver Tappe 	void* converter;
31ec99f3b2SOliver Tappe 	char charset[64];
32fa02fc69SOliver Tappe 	unsigned int count;
33*63fe8ecdSIthamar R. Adema 	char data[1024 + 8];	/* 1024 bytes for data, 8 for alignment space */
34abd010bcSJérôme Duval } mbstate_t;
35abd010bcSJérôme Duval 
360cb1c46aSshatty 
37510c100aSOliver Tappe #define WEOF		((wint_t)(-1))
38510c100aSOliver Tappe 
39510c100aSOliver Tappe #define WCHAR_MIN	0x00000000UL
40510c100aSOliver Tappe #define WCHAR_MAX	0x7FFFFFFFUL
41510c100aSOliver Tappe 
42a3f66598SOliver Tappe /*
43a3f66598SOliver Tappe  * Haiku is always using UTF32 in wchars, other encodings can be handled
44cfe553b3SOliver Tappe  * by converting to/from wchar by means of mbrtowc() or wcrtomb().
45a3f66598SOliver Tappe  */
46a3f66598SOliver Tappe 
47510c100aSOliver Tappe 
4830589be5SIngo Weinhold #ifdef __cplusplus
4930589be5SIngo Weinhold extern "C" {
5030589be5SIngo Weinhold #endif
5130589be5SIngo Weinhold 
52510c100aSOliver Tappe extern wint_t	btowc(int);
53510c100aSOliver Tappe 
54b7417fbeSOliver Tappe extern wint_t	fgetwc(FILE *stream);
55b7417fbeSOliver Tappe extern wchar_t	*fgetws(wchar_t *dest, int destLength, FILE *stream);
56b7417fbeSOliver Tappe extern wint_t	fputwc(wchar_t wc, FILE *stream);
57b7417fbeSOliver Tappe extern int		fputws(const wchar_t *wcs, FILE *stream);
58b7417fbeSOliver Tappe extern int		fwide(FILE *stream, int mode);
59b7417fbeSOliver Tappe extern int		fwprintf(FILE *stream, const wchar_t *format, ...);
60b7417fbeSOliver Tappe extern int		fwscanf(FILE *stream, const wchar_t *format, ...);
61b7417fbeSOliver Tappe extern wint_t	getwc(FILE *stream);
62a34963f3SJérôme Duval extern wint_t	getwchar(void);
63a34963f3SJérôme Duval 
64b7417fbeSOliver Tappe extern size_t 	mbrlen(const char *s, size_t n, mbstate_t *mbState);
65752527a8SOliver Tappe extern size_t 	mbrtowc(wchar_t *dest, const char *src, size_t srcLength,
66b7417fbeSOliver Tappe 					mbstate_t *mbState);
67b7417fbeSOliver Tappe extern int		mbsinit(const mbstate_t *mbState);
68b7417fbeSOliver Tappe extern size_t	mbsnrtowcs(wchar_t *dest, const char **src, size_t srcLength,
69b7417fbeSOliver Tappe 					size_t destLength, mbstate_t *mbState);
70b7417fbeSOliver Tappe extern size_t	mbsrtowcs(wchar_t *dest, const char **src, size_t destLength,
71b7417fbeSOliver Tappe 					mbstate_t *mbState);
72a34963f3SJérôme Duval 
73b7417fbeSOliver Tappe extern wint_t	putwc(wchar_t wc, FILE *stream);
74b7417fbeSOliver Tappe extern wint_t	putwchar(wchar_t wc);
75a34963f3SJérôme Duval 
76b7417fbeSOliver Tappe extern int		swprintf(wchar_t *dest, size_t destLength,
77b7417fbeSOliver Tappe 					const wchar_t *format, ...);
78b7417fbeSOliver Tappe extern int		swscanf(const wchar_t *wcs, const wchar_t *format, ...);
79a34963f3SJérôme Duval 
80b7417fbeSOliver Tappe extern wint_t	ungetwc(wint_t wc, FILE *stream);
81a34963f3SJérôme Duval 
82b7417fbeSOliver Tappe extern int		vfwprintf(FILE *stream, const wchar_t *format, va_list arg);
83b7417fbeSOliver Tappe extern int		vfwscanf(FILE *stream, const wchar_t *format, va_list arg);
84b7417fbeSOliver Tappe extern int		vswprintf(wchar_t *dest, size_t destLength,
85b7417fbeSOliver Tappe 					const wchar_t *format, va_list arg);
86b7417fbeSOliver Tappe extern int		vswscanf(const wchar_t *wcs, const wchar_t *format,
87b7417fbeSOliver Tappe 					va_list arg);
88b7417fbeSOliver Tappe extern int		vwprintf(const wchar_t *format, va_list arg);
89b7417fbeSOliver Tappe extern int		vwscanf(const wchar_t *format, va_list arg);
90510c100aSOliver Tappe 
91b7417fbeSOliver Tappe extern wchar_t	*wcpcpy(wchar_t *dest, const wchar_t *src);
92b7417fbeSOliver Tappe extern wchar_t	*wcpncpy(wchar_t *dest, const wchar_t *src, size_t srcLength);
93b7417fbeSOliver Tappe extern size_t   wcrtomb(char *dest, wchar_t wc, mbstate_t *mbState);
94b7417fbeSOliver Tappe extern int		wcscasecmp(const wchar_t *wcs1, const wchar_t *wcs2);
95b7417fbeSOliver Tappe extern wchar_t	*wcscat(wchar_t *dest, const wchar_t *src);
96b7417fbeSOliver Tappe extern wchar_t	*wcschr(const wchar_t *wcs, wchar_t wc);
97b7417fbeSOliver Tappe #ifdef __USE_GNU
98b7417fbeSOliver Tappe extern wchar_t	*wcschrnul(const wchar_t *wcs, wchar_t wc);
99b7417fbeSOliver Tappe #endif
100b7417fbeSOliver Tappe extern int      wcscmp(const wchar_t *wcs1, const wchar_t *wcs2);
101b7417fbeSOliver Tappe extern int      wcscoll(const wchar_t *wcs1, const wchar_t *wcs2);
102b7417fbeSOliver Tappe extern wchar_t	*wcscpy(wchar_t *dest, const wchar_t *src);
103b7417fbeSOliver Tappe extern size_t	wcscspn(const wchar_t *wcs, const wchar_t *reject);
104b7417fbeSOliver Tappe extern wchar_t	*wcsdup(const wchar_t *wcs);
105b7417fbeSOliver Tappe extern size_t	wcsftime(wchar_t *dest, size_t destLength,
106b7417fbeSOliver Tappe 					const wchar_t *format, const struct tm *time);
107b7417fbeSOliver Tappe extern size_t	wcslcat(wchar_t *dest, const wchar_t *src, size_t maxLength);
108b7417fbeSOliver Tappe extern size_t	wcslcpy(wchar_t *dest, const wchar_t *src, size_t maxLength);
109b7417fbeSOliver Tappe extern size_t	wcslen(const wchar_t *wcs);
110b7417fbeSOliver Tappe extern int		wcsncasecmp(const wchar_t *wcs1, const wchar_t *wcs2,
111b7417fbeSOliver Tappe 					size_t maxLength);
112b7417fbeSOliver Tappe extern wchar_t 	*wcsncat(wchar_t *dest, const wchar_t *src, size_t srcLength);
113b7417fbeSOliver Tappe extern int		wcsncmp(const wchar_t *wcs1, const wchar_t *wcs2,
114b7417fbeSOliver Tappe 					size_t length);
115b7417fbeSOliver Tappe extern wchar_t	*wcsncpy(wchar_t *dest, const wchar_t *src, size_t srcLength);
116b7417fbeSOliver Tappe extern size_t	wcsnlen(const wchar_t *wcs, size_t maxLength);
117b7417fbeSOliver Tappe extern size_t   wcsnrtombs(char *dest, const wchar_t **src, size_t srcLength,
118b7417fbeSOliver Tappe 					size_t destLength, mbstate_t *mbState);
119b7417fbeSOliver Tappe extern wchar_t	*wcspbrk(const wchar_t *wcs, const wchar_t *accept);
120b7417fbeSOliver Tappe extern wchar_t	*wcsrchr(const wchar_t *wcs, wchar_t wc);
121b7417fbeSOliver Tappe extern size_t   wcsrtombs(char *dest, const wchar_t **src, size_t destLength,
122b7417fbeSOliver Tappe 					mbstate_t *mbState);
123b7417fbeSOliver Tappe extern size_t	wcsspn(const wchar_t *wcs, const wchar_t *accept);
124b7417fbeSOliver Tappe extern wchar_t	*wcsstr(const wchar_t *haystack, const wchar_t *needle);
125b7417fbeSOliver Tappe extern double	wcstod(const wchar_t *wcs, wchar_t **endPtr);
126b7417fbeSOliver Tappe extern float	wcstof(const wchar_t *wcs, wchar_t **endPtr);
127b7417fbeSOliver Tappe extern wchar_t	*wcstok(wchar_t *wcs1, const wchar_t *wcs2, wchar_t **ptr);
128b7417fbeSOliver Tappe extern long		wcstol(const wchar_t *wcs, wchar_t **endPtr, int base);
129b7417fbeSOliver Tappe extern long double	wcstold(const wchar_t *wcs, wchar_t **endPtr);
130b7417fbeSOliver Tappe extern long long	wcstoll(const wchar_t *wcs, wchar_t **endPtr, int base);
131b7417fbeSOliver Tappe extern unsigned long	wcstoul(const wchar_t *wcs, wchar_t **endPtr,
132b7417fbeSOliver Tappe 							int base);
133b7417fbeSOliver Tappe extern unsigned long long	wcstoull(const wchar_t *wcs, wchar_t **endPtr,
134b7417fbeSOliver Tappe 								int base);
135b7417fbeSOliver Tappe extern wchar_t	*wcswcs(const wchar_t *haystack, const wchar_t *needle);
136b7417fbeSOliver Tappe extern int		wcswidth(const wchar_t *wcs, size_t length);
137b7417fbeSOliver Tappe extern size_t	wcsxfrm(wchar_t *dest, const wchar_t *src, size_t destLength);
138b7417fbeSOliver Tappe extern int		wctob(wint_t wc);
139b7417fbeSOliver Tappe extern int		wcwidth(wchar_t wc);
140b7417fbeSOliver Tappe extern wchar_t	*wmemchr(const wchar_t *wcs, wchar_t wc, size_t n);
141b7417fbeSOliver Tappe extern int		wmemcmp(const wchar_t *wcs1, const wchar_t *wcs2, size_t n);
142b7417fbeSOliver Tappe extern wchar_t	*wmemcpy(wchar_t *dest, const wchar_t *src, size_t n);
143b7417fbeSOliver Tappe extern wchar_t	*wmemmove(wchar_t *dest, const wchar_t *src, size_t n);
144b7417fbeSOliver Tappe #ifdef __USE_GNU
145b7417fbeSOliver Tappe extern wchar_t	*wmempcpy(wchar_t *dest, const wchar_t *src, size_t n);
146b7417fbeSOliver Tappe #endif
147b7417fbeSOliver Tappe extern wchar_t	*wmemset(wchar_t *dest, wchar_t wc, size_t n);
148b7417fbeSOliver Tappe 
149b7417fbeSOliver Tappe extern int		wprintf(const wchar_t *format, ...);
150b7417fbeSOliver Tappe extern int		wscanf(const wchar_t *format, ...);
151e0f9a4e8SJérôme Duval 
15230589be5SIngo Weinhold #ifdef __cplusplus
15330589be5SIngo Weinhold }
15430589be5SIngo Weinhold #endif
15530589be5SIngo Weinhold 
1560cb1c46aSshatty #endif /* _WCHAR_H */
157