uchar.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Copyright (C) 2011-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C11 Standard: 7.28
  16. * Unicode utilities <uchar.h>
  17. */
  18. #ifndef _UCHAR_H
  19. #define _UCHAR_H 1
  20. #include <features.h>
  21. #define __need_size_t
  22. #include <stddef.h>
  23. #include <bits/types.h>
  24. #include <bits/types/mbstate_t.h>
  25. #if __GLIBC_USE (ISOC23)
  26. # define __STDC_VERSION_UCHAR_H__ 202311L
  27. #endif
  28. /* Declare the C23 char8_t typedef in C23 modes, but only if the C++
  29. __cpp_char8_t feature test macro is not defined. */
  30. #if __GLIBC_USE (ISOC23) && !defined __cpp_char8_t
  31. #if __GNUC_PREREQ (10, 0) && defined __cplusplus
  32. /* Suppress the diagnostic regarding char8_t being a keyword in C++20. */
  33. # pragma GCC diagnostic push
  34. # pragma GCC diagnostic ignored "-Wc++20-compat"
  35. #endif
  36. /* Define the 8-bit character type. */
  37. typedef unsigned char char8_t;
  38. #if __GNUC_PREREQ (10, 0) && defined __cplusplus
  39. # pragma GCC diagnostic pop
  40. #endif
  41. #endif
  42. #ifndef __USE_ISOCXX11
  43. /* Define the 16-bit and 32-bit character types. */
  44. typedef __uint_least16_t char16_t;
  45. typedef __uint_least32_t char32_t;
  46. #endif
  47. __BEGIN_DECLS
  48. /* Declare the C23 mbrtoc8() and c8rtomb() functions in C23 modes or if
  49. the C++ __cpp_char8_t feature test macro is defined. */
  50. #if __GLIBC_USE (ISOC23) || defined __cpp_char8_t
  51. /* Write char8_t representation of multibyte character pointed
  52. to by S to PC8. */
  53. extern size_t mbrtoc8 (char8_t *__restrict __pc8,
  54. const char *__restrict __s, size_t __n,
  55. mbstate_t *__restrict __p) __THROW;
  56. /* Write multibyte representation of char8_t C8 to S. */
  57. extern size_t c8rtomb (char *__restrict __s, char8_t __c8,
  58. mbstate_t *__restrict __ps) __THROW;
  59. #endif
  60. /* Write char16_t representation of multibyte character pointed
  61. to by S to PC16. */
  62. extern size_t mbrtoc16 (char16_t *__restrict __pc16,
  63. const char *__restrict __s, size_t __n,
  64. mbstate_t *__restrict __p) __THROW;
  65. /* Write multibyte representation of char16_t C16 to S. */
  66. extern size_t c16rtomb (char *__restrict __s, char16_t __c16,
  67. mbstate_t *__restrict __ps) __THROW;
  68. /* Write char32_t representation of multibyte character pointed
  69. to by S to PC32. */
  70. extern size_t mbrtoc32 (char32_t *__restrict __pc32,
  71. const char *__restrict __s, size_t __n,
  72. mbstate_t *__restrict __p) __THROW;
  73. /* Write multibyte representation of char32_t C32 to S. */
  74. extern size_t c32rtomb (char *__restrict __s, char32_t __c32,
  75. mbstate_t *__restrict __ps) __THROW;
  76. __END_DECLS
  77. #endif /* uchar.h */