From 2c52688f850f44952646a511b9e7ca155f6f9bc9 Mon Sep 17 00:00:00 2001
From: Leorize <alaviss@users.noreply.github.com>
Date: Sat, 13 Jan 2018 11:22:51 +0700
Subject: [PATCH] uchar: Introduce C11 uchar.h
Currently this implementation only supports UTF-32
---
headers/posix/uchar.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 headers/posix/uchar.h
diff --git a/headers/posix/uchar.h b/headers/posix/uchar.h
new file mode 100644
index 00000000..72f3ac18
-
|
+
|
|
| 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 */ |