xref: /haiku/headers/posix/uchar.h (revision d284f7cc43cc0d1106c3b0c40e62c58107648573)
1 /*
2  * Copyright 2018 Haiku, Inc. All Right Reserved
3  * Distributed under the terms of MIT license.
4  */
5 #ifndef _UCHAR_H
6 #define _UCHAR_H
7 
8 #include <wchar.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #else
13 typedef wchar_t char32_t; /* our wchar_t is utf32 */
14 typedef wchar_t char16_t;
15 #endif
16 
17 #define __STD_UTF_32__ 1
18 
19 /* We don't define __STD_UTF_16__, so the format of char16_t is unspecified */
20 static __inline size_t
21 c16rtomb(char *dest, char16_t wc, mbstate_t *mbState)
22 {
23 	return wcrtomb(dest, wc, mbState);
24 }
25 static __inline size_t
26 mbrtoc16(char16_t *dest, const char *src, size_t srcLength, mbstate_t *mbState)
27 {
28 	return mbrtowc(dest, src, srcLength, mbState);
29 }
30 
31 static __inline size_t
32 c32rtomb(char *dest, char32_t wc, mbstate_t *mbState)
33 {
34 	return wcrtomb(dest, wc, mbState);
35 }
36 static __inline size_t
37 mbrtoc32(char32_t *dest, const char *src, size_t srcLength, mbstate_t *mbState)
38 {
39 	return mbrtowc(dest, src, srcLength, mbState);
40 }
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 #endif /* _UCHAR_H */
46