c6056b37600872678691ed07c8c66bed451922bd
[gnulib.git] / lib / unigbrk.in.h
1 /* Grapheme cluster breaks in Unicode strings.
2    Copyright (C) 2010 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@cs.stanford.edu>, 2010.
4
5    This program is free software: you can redistribute it and/or modify it
6    under the terms of the GNU Lesser General Public License as published
7    by the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 #ifndef _UNIGBRK_H
19 #define _UNIGBRK_H
20
21 /* Get bool.  */
22 #include <stdbool.h>
23
24 #include "unitypes.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /* ========================================================================= */
31
32 /* Property defined in Unicode Standard Annex #29, section "Grapheme Cluster
33    Boundaries"
34    <http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries> */
35
36 /* Possible values of the Grapheme_Cluster_Break property.
37    This enumeration may be extended in the future.  */
38 enum
39 {
40   GBP_OTHER        = 0,
41   GBP_CR           = 1,
42   GBP_LF           = 2,
43   GBP_CONTROL      = 3,
44   GBP_EXTEND       = 4,
45   GBP_PREPEND      = 5,
46   GBP_SPACINGMARK  = 6,
47   GBP_L            = 7,
48   GBP_V            = 8,
49   GBP_T            = 9,
50   GBP_LV           = 10,
51   GBP_LVT          = 11
52 };
53
54 /* Return the Grapheme_Cluster_Break property of a Unicode character. */
55 extern int
56        uc_graphemeclusterbreak_property (ucs4_t uc);
57
58 /* ========================================================================= */
59
60 /* Grapheme cluster breaks.  */
61
62 /* Returns true if there is an grapheme cluster boundary between Unicode code
63    points A and B.  A "grapheme cluster" is an approximation to a
64    user-perceived character, which sometimes corresponds to multiple code
65    points.  For example, an English letter followed by an acute accent can be
66    expressed as two consecutive Unicode code points, but it is perceived by the
67    user as only a single character and therefore constitutes a single grapheme
68    cluster.
69
70    Implements extended (not legacy) grapheme cluster rules, because UAX #29
71    indicates that they are preferred.
72
73    Use A == 0 or B == 0 to indicate start of text or end of text,
74    respectively. */
75 extern bool
76        uc_is_grapheme_cluster_break (ucs4_t a, ucs4_t b);
77
78 /* ========================================================================= */
79
80 #ifdef __cplusplus
81 }
82 #endif
83
84
85 #endif /* _UNIGBRK_H */