1 /* Line breaking of Unicode strings.
2 Copyright (C) 2001-2003, 2005-2024 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2001.
5 This file is free software.
6 It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
7 You can redistribute it and/or modify it under either
8 - the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation, either version 3, or (at your
10 option) any later version, or
11 - the terms of the GNU General Public License as published by the
12 Free Software Foundation; either version 2, or (at your option)
14 - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
16 This file is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License and the GNU General Public License
22 You should have received a copy of the GNU Lesser General Public
23 License and of the GNU General Public License along with this
24 program. If not, see <https://www.gnu.org/licenses/>. */
34 /* Get locale_charset() declaration. */
35 #include "localcharset.h"
43 /* These functions are locale dependent. The encoding argument identifies
44 the encoding (e.g. "ISO-8859-2" for Polish). */
56 UC_BREAK_CR_BEFORE_LF
/* only used in _v2 or later */
59 /* Determine the line break points in S, and store the result at p[0..n-1].
60 p[i] = UC_BREAK_MANDATORY means that s[i] is a line break character.
61 p[i] = UC_BREAK_CR_BEFORE_LF means that s[i] and s[i+1] is the CR-LF
62 character sequence. (Only used in _v2 or later.)
63 p[i] = UC_BREAK_POSSIBLE means that a line break may be inserted between
65 p[i] = UC_BREAK_HYPHENATION means that a hyphen and a line break may be
66 inserted between s[i-1] and s[i]. But beware of language dependent
68 p[i] = UC_BREAK_PROHIBITED means that s[i-1] and s[i] must not be separated.
71 u8_possible_linebreaks (const uint8_t *s
, size_t n
,
72 const char *encoding
, char *_UC_RESTRICT p
);
74 u8_possible_linebreaks_v2 (const uint8_t *s
, size_t n
,
75 const char *encoding
, char *_UC_RESTRICT p
);
76 #define u8_possible_linebreaks u8_possible_linebreaks_v2
79 u16_possible_linebreaks (const uint16_t *s
, size_t n
,
80 const char *encoding
, char *_UC_RESTRICT p
);
82 u16_possible_linebreaks_v2 (const uint16_t *s
, size_t n
,
83 const char *encoding
, char *_UC_RESTRICT p
);
84 #define u16_possible_linebreaks u16_possible_linebreaks_v2
87 u32_possible_linebreaks (const uint32_t *s
, size_t n
,
88 const char *encoding
, char *_UC_RESTRICT p
);
90 u32_possible_linebreaks_v2 (const uint32_t *s
, size_t n
,
91 const char *encoding
, char *_UC_RESTRICT p
);
92 #define u32_possible_linebreaks u32_possible_linebreaks_v2
95 ulc_possible_linebreaks (const char *s
, size_t n
,
96 const char *encoding
, char *_UC_RESTRICT p
);
98 ulc_possible_linebreaks_v2 (const char *s
, size_t n
,
99 const char *encoding
, char *_UC_RESTRICT p
);
100 #define ulc_possible_linebreaks ulc_possible_linebreaks_v2
102 /* Choose the best line breaks, assuming the uc_width function.
103 The string is s[0..n-1]. The maximum number of columns per line is given
104 as WIDTH. The starting column of the string is given as START_COLUMN.
105 If the algorithm shall keep room after the last piece, they can be given
107 o is an optional override; if o[i] != UC_BREAK_UNDEFINED, o[i] takes
108 precedence over p[i] as returned by the *_possible_linebreaks function.
109 The given ENCODING is used for disambiguating widths in uc_width.
110 Return the column after the end of the string, and store the result at
114 u8_width_linebreaks (const uint8_t *s
, size_t n
, int width
,
115 int start_column
, int at_end_columns
,
116 const char *o
, const char *encoding
,
117 char *_UC_RESTRICT p
);
119 u8_width_linebreaks_v2 (const uint8_t *s
, size_t n
, int width
,
120 int start_column
, int at_end_columns
,
121 const char *o
, const char *encoding
,
122 char *_UC_RESTRICT p
);
123 #define u8_width_linebreaks u8_width_linebreaks_v2
126 u16_width_linebreaks (const uint16_t *s
, size_t n
, int width
,
127 int start_column
, int at_end_columns
,
128 const char *o
, const char *encoding
,
129 char *_UC_RESTRICT p
);
131 u16_width_linebreaks_v2 (const uint16_t *s
, size_t n
, int width
,
132 int start_column
, int at_end_columns
,
133 const char *o
, const char *encoding
,
134 char *_UC_RESTRICT p
);
135 #define u16_width_linebreaks u16_width_linebreaks_v2
138 u32_width_linebreaks (const uint32_t *s
, size_t n
, int width
,
139 int start_column
, int at_end_columns
,
140 const char *o
, const char *encoding
,
141 char *_UC_RESTRICT p
);
143 u32_width_linebreaks_v2 (const uint32_t *s
, size_t n
, int width
,
144 int start_column
, int at_end_columns
,
145 const char *o
, const char *encoding
,
146 char *_UC_RESTRICT p
);
147 #define u32_width_linebreaks u32_width_linebreaks_v2
150 ulc_width_linebreaks (const char *s
, size_t n
, int width
,
151 int start_column
, int at_end_columns
,
152 const char *o
, const char *encoding
,
153 char *_UC_RESTRICT p
);
155 ulc_width_linebreaks_v2 (const char *s
, size_t n
, int width
,
156 int start_column
, int at_end_columns
,
157 const char *o
, const char *encoding
,
158 char *_UC_RESTRICT p
);
159 #define ulc_width_linebreaks ulc_width_linebreaks_v2
167 #endif /* _UNILBRK_H */