2014-06-02 20:33:04 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2018-08-22 01:10:48 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file uchar.h
|
|
|
|
* @brief Unicode functions.
|
|
|
|
*/
|
2014-06-02 20:33:04 +02:00
|
|
|
|
2016-07-27 19:45:05 +02:00
|
|
|
#include <stddef.h>
|
2014-06-02 20:33:04 +02:00
|
|
|
#include <sys/cdefs.h>
|
2023-07-21 23:41:55 +02:00
|
|
|
|
|
|
|
#include <bits/bionic_multibyte_result.h>
|
2016-07-27 19:45:05 +02:00
|
|
|
#include <bits/mbstate_t.h>
|
2014-06-02 20:33:04 +02:00
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2016-06-08 19:52:15 +02:00
|
|
|
#if !defined(__cplusplus)
|
2018-08-22 01:10:48 +02:00
|
|
|
/** The UTF-16 character type. */
|
2015-04-24 16:21:38 +02:00
|
|
|
typedef __CHAR16_TYPE__ char16_t;
|
2018-08-22 01:10:48 +02:00
|
|
|
/** The UTF-32 character type. */
|
2015-04-24 16:21:38 +02:00
|
|
|
typedef __CHAR32_TYPE__ char32_t;
|
|
|
|
#endif
|
|
|
|
|
2018-08-22 01:10:48 +02:00
|
|
|
/** On Android, char16_t is UTF-16. */
|
2014-06-02 20:33:04 +02:00
|
|
|
#define __STD_UTF_16__ 1
|
2018-08-22 01:10:48 +02:00
|
|
|
|
|
|
|
/** On Android, char32_t is UTF-32. */
|
2014-06-02 20:33:04 +02:00
|
|
|
#define __STD_UTF_32__ 1
|
|
|
|
|
2018-08-22 01:10:48 +02:00
|
|
|
/**
|
|
|
|
* [c16rtomb(3)](http://man7.org/linux/man-pages/man3/c16rtomb.3.html) converts a single UTF-16
|
|
|
|
* character to UTF-8.
|
|
|
|
*
|
|
|
|
* Returns the number of bytes written to `__buf` on success, and returns -1 and sets `errno`
|
|
|
|
* on failure.
|
|
|
|
*/
|
2023-06-16 21:39:33 +02:00
|
|
|
size_t c16rtomb(char* _Nullable __buf, char16_t __ch16, mbstate_t* _Nullable __ps);
|
2014-06-02 20:33:04 +02:00
|
|
|
|
2018-08-22 01:10:48 +02:00
|
|
|
/**
|
|
|
|
* [c32rtomb(3)](http://man7.org/linux/man-pages/man3/c32rtomb.3.html) converts a single UTF-32
|
|
|
|
* character to UTF-8.
|
|
|
|
*
|
|
|
|
* Returns the number of bytes written to `__buf` on success, and returns -1 and sets `errno`
|
|
|
|
* on failure.
|
|
|
|
*/
|
2023-06-16 21:39:33 +02:00
|
|
|
size_t c32rtomb(char* _Nullable __buf, char32_t __ch32, mbstate_t* _Nullable __ps);
|
2014-06-02 20:33:04 +02:00
|
|
|
|
2018-08-22 01:10:48 +02:00
|
|
|
/**
|
|
|
|
* [mbrtoc16(3)](http://man7.org/linux/man-pages/man3/mbrtoc16.3.html) converts the next UTF-8
|
|
|
|
* sequence to a UTF-16 code point.
|
|
|
|
*/
|
2023-06-16 21:39:33 +02:00
|
|
|
size_t mbrtoc16(char16_t* _Nullable __ch16, const char* _Nullable __s, size_t __n, mbstate_t* _Nullable __ps);
|
2018-08-22 01:10:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [mbrtoc32(3)](http://man7.org/linux/man-pages/man3/mbrtoc32.3.html) converts the next UTF-8
|
|
|
|
* sequence to a UTF-32 code point.
|
|
|
|
*/
|
2023-06-16 21:39:33 +02:00
|
|
|
size_t mbrtoc32(char32_t* _Nullable __ch32, const char* _Nullable __s, size_t __n, mbstate_t* _Nullable __ps);
|
2018-08-22 01:10:48 +02:00
|
|
|
|
|
|
|
__END_DECLS
|