bitset: properly use false/true instead of 0/1 for Booleans
[gnulib.git] / lib / unilbrk.in.h
blob7c24730095d52abcdb6672cffccacef6dce82ad9
1 /* Line breaking of Unicode strings.
2 Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2001.
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.
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.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #ifndef _UNILBRK_H
19 #define _UNILBRK_H
21 /* Get size_t. */
22 #include <stddef.h>
24 #include "unitypes.h"
26 /* Get locale_charset() declaration. */
27 #include "localcharset.h"
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
35 /* These functions are locale dependent. The encoding argument identifies
36 the encoding (e.g. "ISO-8859-2" for Polish). */
39 /* Line breaking. */
41 enum
43 UC_BREAK_UNDEFINED,
44 UC_BREAK_PROHIBITED,
45 UC_BREAK_POSSIBLE,
46 UC_BREAK_MANDATORY,
47 UC_BREAK_HYPHENATION
50 /* Determine the line break points in S, and store the result at p[0..n-1].
51 p[i] = UC_BREAK_MANDATORY means that s[i] is a line break character.
52 p[i] = UC_BREAK_POSSIBLE means that a line break may be inserted between
53 s[i-1] and s[i].
54 p[i] = UC_BREAK_HYPHENATION means that a hyphen and a line break may be
55 inserted between s[i-1] and s[i]. But beware of language dependent
56 hyphenation rules.
57 p[i] = UC_BREAK_PROHIBITED means that s[i-1] and s[i] must not be separated.
59 extern void
60 u8_possible_linebreaks (const uint8_t *s, size_t n,
61 const char *encoding, char *p);
62 extern void
63 u16_possible_linebreaks (const uint16_t *s, size_t n,
64 const char *encoding, char *p);
65 extern void
66 u32_possible_linebreaks (const uint32_t *s, size_t n,
67 const char *encoding, char *p);
68 extern void
69 ulc_possible_linebreaks (const char *s, size_t n,
70 const char *encoding, char *p);
72 /* Choose the best line breaks, assuming the uc_width function.
73 The string is s[0..n-1]. The maximum number of columns per line is given
74 as WIDTH. The starting column of the string is given as START_COLUMN.
75 If the algorithm shall keep room after the last piece, they can be given
76 as AT_END_COLUMNS.
77 o is an optional override; if o[i] != UC_BREAK_UNDEFINED, o[i] takes
78 precedence over p[i] as returned by the *_possible_linebreaks function.
79 The given ENCODING is used for disambiguating widths in uc_width.
80 Return the column after the end of the string, and store the result at
81 p[0..n-1].
83 extern int
84 u8_width_linebreaks (const uint8_t *s, size_t n, int width,
85 int start_column, int at_end_columns,
86 const char *o, const char *encoding,
87 char *p);
88 extern int
89 u16_width_linebreaks (const uint16_t *s, size_t n, int width,
90 int start_column, int at_end_columns,
91 const char *o, const char *encoding,
92 char *p);
93 extern int
94 u32_width_linebreaks (const uint32_t *s, size_t n, int width,
95 int start_column, int at_end_columns,
96 const char *o, const char *encoding,
97 char *p);
98 extern int
99 ulc_width_linebreaks (const char *s, size_t n, int width,
100 int start_column, int at_end_columns,
101 const char *o, const char *encoding,
102 char *p);
105 #ifdef __cplusplus
107 #endif
110 #endif /* _UNILBRK_H */