uchar: Introduce C11 uchar.h
Currently this implementation only supports UTF-32
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Haiku, Inc. All Right Reserved
|
||||||
|
* Distributed under the terms of MIT license.
|
||||||
|
*/
|
||||||
|
#ifndef _UCHAR_H
|
||||||
|
#define _UCHAR_H
|
||||||
|
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#else
|
||||||
|
typedef wchar_t char32_t; /* our wchar_t is utf32 */
|
||||||
|
typedef wchar_t char16_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __STD_UTF_32__ 1
|
||||||
|
|
||||||
|
/* We don't define __STD_UTF_16__, so the format of char16_t is unspecified */
|
||||||
|
static __inline size_t
|
||||||
|
c16rtomb(char *dest, char16_t wc, mbstate_t *mbState)
|
||||||
|
{
|
||||||
|
return wcrtomb(dest, wc, mbState);
|
||||||
|
}
|
||||||
|
static __inline size_t
|
||||||
|
mbrtoc16(char16_t *dest, const char *src, size_t srcLength, mbstate_t *mbState)
|
||||||
|
{
|
||||||
|
return mbrtowc(dest, src, srcLength, mbState);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline size_t
|
||||||
|
c32rtomb(char *dest, char32_t wc, mbstate_t *mbState)
|
||||||
|
{
|
||||||
|
return wcrtomb(dest, wc, mbState);
|
||||||
|
}
|
||||||
|
static __inline size_t
|
||||||
|
mbrtoc32(char32_t *dest, const char *src, size_t srcLength, mbstate_t *mbState)
|
||||||
|
{
|
||||||
|
return mbrtowc(dest, src, srcLength, mbState);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* _UCHAR_H */
|
||||||
Reference in New Issue
Block a user