1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Grapheme cluster breaks in Unicode strings.
3 Copyright (C) 2010-2014 Free Software Foundation, Inc.
4 Written by Ben Pfaff <blp@cs.stanford.edu>, 2010.
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include <unistring/stdbool.h>
34 /* ========================================================================= */
36 /* Property defined in Unicode Standard Annex #29, section "Grapheme Cluster
38 <http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries> */
40 /* Possible values of the Grapheme_Cluster_Break property.
41 This enumeration may be extended in the future. */
58 /* Return the Grapheme_Cluster_Break property of a Unicode character. */
60 uc_graphemeclusterbreak_property (ucs4_t uc)
63 /* ========================================================================= */
65 /* Grapheme cluster breaks. */
67 /* Returns true if there is a grapheme cluster boundary between Unicode code
68 points A and B. A "grapheme cluster" is an approximation to a
69 user-perceived character, which sometimes corresponds to multiple code
70 points. For example, an English letter followed by an acute accent can be
71 expressed as two consecutive Unicode code points, but it is perceived by the
72 user as only a single character and therefore constitutes a single grapheme
75 Implements extended (not legacy) grapheme cluster rules, because UAX #29
76 indicates that they are preferred.
78 Use A == 0 or B == 0 to indicate start of text or end of text,
81 uc_is_grapheme_break (ucs4_t a, ucs4_t b)
84 /* Returns the start of the next grapheme cluster following S, or NULL if the
85 end of the string has been reached. */
86 extern const uint8_t *
87 u8_grapheme_next (const uint8_t *s, const uint8_t *end)
89 extern const uint16_t *
90 u16_grapheme_next (const uint16_t *s, const uint16_t *end)
92 extern const uint32_t *
93 u32_grapheme_next (const uint32_t *s, const uint32_t *end)
96 /* Returns the start of the previous grapheme cluster before S, or NULL if the
97 start of the string has been reached. */
98 extern const uint8_t *
99 u8_grapheme_prev (const uint8_t *s, const uint8_t *start)
101 extern const uint16_t *
102 u16_grapheme_prev (const uint16_t *s, const uint16_t *start)
104 extern const uint32_t *
105 u32_grapheme_prev (const uint32_t *s, const uint32_t *start)
108 /* Determine the grapheme cluster boundaries in S, and store the result at
109 p[0..n-1]. p[i] = 1 means that a new grapheme cluster begins at s[i]. p[i]
110 = 0 means that s[i-1] and s[i] are part of the same grapheme cluster. p[0]
114 u8_grapheme_breaks (const uint8_t *s, size_t n, char *p);
116 u16_grapheme_breaks (const uint16_t *s, size_t n, char *p);
118 u32_grapheme_breaks (const uint32_t *s, size_t n, char *p);
120 ulc_grapheme_breaks (const char *s, size_t n, char *p);
122 /* ========================================================================= */
129 #endif /* _UNIGBRK_H */