1/* gunibreak.c - line break properties
2 *
3 * Copyright 2000 Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 library; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "config.h"
20
21#include <stdlib.h>
22
23#include "gunibreak.h"
24
25#define TPROP_PART1(Page, Char) \
26 ((break_property_table_part1[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
27 ? (break_property_table_part1[Page] - G_UNICODE_MAX_TABLE_INDEX) \
28 : (break_property_data[break_property_table_part1[Page]][Char]))
29
30#define TPROP_PART2(Page, Char) \
31 ((break_property_table_part2[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
32 ? (break_property_table_part2[Page] - G_UNICODE_MAX_TABLE_INDEX) \
33 : (break_property_data[break_property_table_part2[Page]][Char]))
34
35#define PROP(Char) \
36 (((Char) <= G_UNICODE_LAST_CHAR_PART1) \
37 ? TPROP_PART1 ((Char) >> 8, (Char) & 0xff) \
38 : (((Char) >= 0xe0000 && (Char) <= G_UNICODE_LAST_CHAR) \
39 ? TPROP_PART2 (((Char) - 0xe0000) >> 8, (Char) & 0xff) \
40 : G_UNICODE_BREAK_UNKNOWN))
41
42/**
43 * g_unichar_break_type:
44 * @c: a Unicode character
45 *
46 * Determines the break type of @c. @c should be a Unicode character
47 * (to derive a character from UTF-8 encoded text, use
48 * g_utf8_get_char()). The break type is used to find word and line
49 * breaks ("text boundaries"), Pango implements the Unicode boundary
50 * resolution algorithms and normally you would use a function such
51 * as pango_break() instead of caring about break types yourself.
52 *
53 * Returns: the break type of @c
54 **/
55GUnicodeBreakType
56g_unichar_break_type (gunichar c)
57{
58 return PROP (c);
59}
60

source code of gtk/subprojects/glib/glib/gunibreak.c