File indexing completed on 2026-09-19 09:43:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef _UNIGBRK_H
0028 #define _UNIGBRK_H
0029
0030
0031 #include <stdbool.h>
0032
0033
0034 #include <stddef.h>
0035
0036 #include "unitypes.h"
0037
0038 #ifdef __cplusplus
0039 extern "C" {
0040 #endif
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 enum
0051 {
0052 GBP_OTHER = 0,
0053 GBP_CR = 1,
0054 GBP_LF = 2,
0055 GBP_CONTROL = 3,
0056 GBP_EXTEND = 4,
0057 GBP_PREPEND = 5,
0058 GBP_SPACINGMARK = 6,
0059 GBP_L = 7,
0060 GBP_V = 8,
0061 GBP_T = 9,
0062 GBP_LV = 10,
0063 GBP_LVT = 11,
0064 GBP_RI = 12,
0065 GBP_ZWJ = 13,
0066 GBP_EB = 14,
0067 GBP_EM = 15,
0068 GBP_GAZ = 16,
0069 GBP_EBG = 17
0070 };
0071
0072
0073 extern int
0074 uc_graphemeclusterbreak_property (ucs4_t uc)
0075 _UC_ATTRIBUTE_CONST;
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 extern bool
0098 uc_is_grapheme_break (ucs4_t a, ucs4_t b)
0099 _UC_ATTRIBUTE_CONST;
0100
0101
0102
0103
0104
0105 extern const uint8_t *
0106 u8_grapheme_next (const uint8_t *s, const uint8_t *end)
0107 _UC_ATTRIBUTE_PURE;
0108 extern const uint16_t *
0109 u16_grapheme_next (const uint16_t *s, const uint16_t *end)
0110 _UC_ATTRIBUTE_PURE;
0111 extern const uint32_t *
0112 u32_grapheme_next (const uint32_t *s, const uint32_t *end)
0113 _UC_ATTRIBUTE_PURE;
0114 #ifndef _LIBUNISTRING_NO_CONST_GENERICS
0115 # ifdef __cplusplus
0116 }
0117 # endif
0118
0119
0120 # ifdef __cplusplus
0121 template <typename T>
0122 T * u8_grapheme_next_template (T* s, const uint8_t *end);
0123 template <>
0124 inline uint8_t * u8_grapheme_next_template (uint8_t *s, const uint8_t *end)
0125 { return const_cast<uint8_t *>(u8_grapheme_next (s, end)); }
0126 template <>
0127 inline const uint8_t * u8_grapheme_next_template (const uint8_t *s, const uint8_t *end)
0128 { return u8_grapheme_next (s, end); }
0129 # undef u8_grapheme_next
0130 # define u8_grapheme_next u8_grapheme_next_template
0131 # elif !defined u8_grapheme_next
0132 # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
0133 || defined __ICC || defined __TINYC__ \
0134 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
0135 # define u8_grapheme_next(s,end) \
0136 _Generic ((s), \
0137 uint8_t *: (uint8_t *) u8_grapheme_next ((s), (end)), \
0138 default : u8_grapheme_next ((s), (end)))
0139 # endif
0140 # endif
0141 # ifdef __cplusplus
0142 template <typename T>
0143 T * u16_grapheme_next_template (T* s, const uint16_t *end);
0144 template <>
0145 inline uint16_t * u16_grapheme_next_template (uint16_t *s, const uint16_t *end)
0146 { return const_cast<uint16_t *>(u16_grapheme_next (s, end)); }
0147 template <>
0148 inline const uint16_t * u16_grapheme_next_template (const uint16_t *s, const uint16_t *end)
0149 { return u16_grapheme_next (s, end); }
0150 # undef u16_grapheme_next
0151 # define u16_grapheme_next u16_grapheme_next_template
0152 # elif !defined u16_grapheme_next
0153 # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
0154 || defined __ICC || defined __TINYC__ \
0155 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
0156 # define u16_grapheme_next(s,end) \
0157 _Generic ((s), \
0158 uint16_t *: (uint16_t *) u16_grapheme_next ((s), (end)), \
0159 default : u16_grapheme_next ((s), (end)))
0160 # endif
0161 # endif
0162 # ifdef __cplusplus
0163 template <typename T>
0164 T * u32_grapheme_next_template (T* s, const uint32_t *end);
0165 template <>
0166 inline uint32_t * u32_grapheme_next_template (uint32_t *s, const uint32_t *end)
0167 { return const_cast<uint32_t *>(u32_grapheme_next (s, end)); }
0168 template <>
0169 inline const uint32_t * u32_grapheme_next_template (const uint32_t *s, const uint32_t *end)
0170 { return u32_grapheme_next (s, end); }
0171 # undef u32_grapheme_next
0172 # define u32_grapheme_next u32_grapheme_next_template
0173 # elif !defined u32_grapheme_next
0174 # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
0175 || defined __ICC || defined __TINYC__ \
0176 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
0177 # define u32_grapheme_next(s,end) \
0178 _Generic ((s), \
0179 uint32_t *: (uint32_t *) u32_grapheme_next ((s), (end)), \
0180 default : u32_grapheme_next ((s), (end)))
0181 # endif
0182 # endif
0183 # ifdef __cplusplus
0184 extern "C" {
0185 # endif
0186 #endif
0187
0188
0189
0190
0191
0192 extern const uint8_t *
0193 u8_grapheme_prev (const uint8_t *s, const uint8_t *start)
0194 _UC_ATTRIBUTE_PURE;
0195 extern const uint16_t *
0196 u16_grapheme_prev (const uint16_t *s, const uint16_t *start)
0197 _UC_ATTRIBUTE_PURE;
0198 extern const uint32_t *
0199 u32_grapheme_prev (const uint32_t *s, const uint32_t *start)
0200 _UC_ATTRIBUTE_PURE;
0201 #ifndef _LIBUNISTRING_NO_CONST_GENERICS
0202 # ifdef __cplusplus
0203 }
0204 # endif
0205
0206
0207 # ifdef __cplusplus
0208 template <typename T>
0209 T * u8_grapheme_prev_template (T* s, const uint8_t *start);
0210 template <>
0211 inline uint8_t * u8_grapheme_prev_template (uint8_t *s, const uint8_t *start)
0212 { return const_cast<uint8_t *>(u8_grapheme_prev (s, start)); }
0213 template <>
0214 inline const uint8_t * u8_grapheme_prev_template (const uint8_t *s, const uint8_t *start)
0215 { return u8_grapheme_prev (s, start); }
0216 # undef u8_grapheme_prev
0217 # define u8_grapheme_prev u8_grapheme_prev_template
0218 # elif !defined u8_grapheme_prev
0219 # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
0220 || defined __ICC || defined __TINYC__ \
0221 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
0222 # define u8_grapheme_prev(s,start) \
0223 _Generic ((s), \
0224 uint8_t *: (uint8_t *) u8_grapheme_prev ((s), (start)), \
0225 default : u8_grapheme_prev ((s), (start)))
0226 # endif
0227 # endif
0228 # ifdef __cplusplus
0229 template <typename T>
0230 T * u16_grapheme_prev_template (T* s, const uint16_t *start);
0231 template <>
0232 inline uint16_t * u16_grapheme_prev_template (uint16_t *s, const uint16_t *start)
0233 { return const_cast<uint16_t *>(u16_grapheme_prev (s, start)); }
0234 template <>
0235 inline const uint16_t * u16_grapheme_prev_template (const uint16_t *s, const uint16_t *start)
0236 { return u16_grapheme_prev (s, start); }
0237 # undef u16_grapheme_prev
0238 # define u16_grapheme_prev u16_grapheme_prev_template
0239 # elif !defined u16_grapheme_prev
0240 # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
0241 || defined __ICC || defined __TINYC__ \
0242 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
0243 # define u16_grapheme_prev(s,start) \
0244 _Generic ((s), \
0245 uint16_t *: (uint16_t *) u16_grapheme_prev ((s), (start)), \
0246 default : u16_grapheme_prev ((s), (start)))
0247 # endif
0248 # endif
0249 # ifdef __cplusplus
0250 template <typename T>
0251 T * u32_grapheme_prev_template (T* s, const uint32_t *start);
0252 template <>
0253 inline uint32_t * u32_grapheme_prev_template (uint32_t *s, const uint32_t *start)
0254 { return const_cast<uint32_t *>(u32_grapheme_prev (s, start)); }
0255 template <>
0256 inline const uint32_t * u32_grapheme_prev_template (const uint32_t *s, const uint32_t *start)
0257 { return u32_grapheme_prev (s, start); }
0258 # undef u32_grapheme_prev
0259 # define u32_grapheme_prev u32_grapheme_prev_template
0260 # elif !defined u32_grapheme_prev
0261 # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
0262 || defined __ICC || defined __TINYC__ \
0263 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
0264 # define u32_grapheme_prev(s,start) \
0265 _Generic ((s), \
0266 uint32_t *: (uint32_t *) u32_grapheme_prev ((s), (start)), \
0267 default : u32_grapheme_prev ((s), (start)))
0268 # endif
0269 # endif
0270 # ifdef __cplusplus
0271 extern "C" {
0272 # endif
0273 #endif
0274
0275
0276
0277
0278
0279
0280 extern void
0281 u8_grapheme_breaks (const uint8_t *s, size_t n, char *p);
0282 extern void
0283 u16_grapheme_breaks (const uint16_t *s, size_t n, char *p);
0284 extern void
0285 u32_grapheme_breaks (const uint32_t *s, size_t n, char *p);
0286 extern void
0287 ulc_grapheme_breaks (const char *s, size_t n, char *p);
0288 extern void
0289 uc_grapheme_breaks (const ucs4_t *s, size_t n, char *p);
0290
0291
0292
0293 #ifdef __cplusplus
0294 }
0295 #endif
0296
0297
0298 #endif