unilbrk.h (6948B)
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 /* Line breaking of Unicode strings. 3 Copyright (C) 2001-2003, 2005-2024 Free Software Foundation, Inc. 4 Written by Bruno Haible <bruno@clisp.org>, 2001. 5 6 This file is free software. 7 It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". 8 You can redistribute it and/or modify it under either 9 - the terms of the GNU Lesser General Public License as published 10 by the Free Software Foundation, either version 3, or (at your 11 option) any later version, or 12 - the terms of the GNU General Public License as published by the 13 Free Software Foundation; either version 2, or (at your option) 14 any later version, or 15 - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+". 16 17 This file is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 Lesser General Public License and the GNU General Public License 21 for more details. 22 23 You should have received a copy of the GNU Lesser General Public 24 License and of the GNU General Public License along with this 25 program. If not, see <https://www.gnu.org/licenses/>. */ 26 27 #ifndef _UNILBRK_H 28 #define _UNILBRK_H 29 30 /* Get size_t. */ 31 #include <stddef.h> 32 33 #include "unitypes.h" 34 35 /* Get locale_charset() declaration. */ 36 #include <unistring/localcharset.h> 37 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 44 /* These functions are locale dependent. The encoding argument identifies 45 the encoding (e.g. "ISO-8859-2" for Polish). */ 46 47 48 /* Line breaking. */ 49 50 enum 51 { 52 UC_BREAK_UNDEFINED, 53 UC_BREAK_PROHIBITED, 54 UC_BREAK_POSSIBLE, 55 UC_BREAK_MANDATORY, 56 UC_BREAK_HYPHENATION, 57 UC_BREAK_CR_BEFORE_LF /* only used in _v2 or later */ 58 }; 59 60 /* Determine the line break points in S, and store the result at p[0..n-1]. 61 p[i] = UC_BREAK_MANDATORY means that s[i] is a line break character. 62 p[i] = UC_BREAK_CR_BEFORE_LF means that s[i] and s[i+1] is the CR-LF 63 character sequence. (Only used in _v2 or later.) 64 p[i] = UC_BREAK_POSSIBLE means that a line break may be inserted between 65 s[i-1] and s[i]. 66 p[i] = UC_BREAK_HYPHENATION means that a hyphen and a line break may be 67 inserted between s[i-1] and s[i]. But beware of language dependent 68 hyphenation rules. 69 p[i] = UC_BREAK_PROHIBITED means that s[i-1] and s[i] must not be separated. 70 */ 71 extern void 72 u8_possible_linebreaks (const uint8_t *s, size_t n, 73 const char *encoding, char *_UC_RESTRICT p); 74 extern void 75 u8_possible_linebreaks_v2 (const uint8_t *s, size_t n, 76 const char *encoding, char *_UC_RESTRICT p); 77 #define u8_possible_linebreaks u8_possible_linebreaks_v2 78 79 extern void 80 u16_possible_linebreaks (const uint16_t *s, size_t n, 81 const char *encoding, char *_UC_RESTRICT p); 82 extern void 83 u16_possible_linebreaks_v2 (const uint16_t *s, size_t n, 84 const char *encoding, char *_UC_RESTRICT p); 85 #define u16_possible_linebreaks u16_possible_linebreaks_v2 86 87 extern void 88 u32_possible_linebreaks (const uint32_t *s, size_t n, 89 const char *encoding, char *_UC_RESTRICT p); 90 extern void 91 u32_possible_linebreaks_v2 (const uint32_t *s, size_t n, 92 const char *encoding, char *_UC_RESTRICT p); 93 #define u32_possible_linebreaks u32_possible_linebreaks_v2 94 95 extern void 96 ulc_possible_linebreaks (const char *s, size_t n, 97 const char *encoding, char *_UC_RESTRICT p); 98 extern void 99 ulc_possible_linebreaks_v2 (const char *s, size_t n, 100 const char *encoding, char *_UC_RESTRICT p); 101 #define ulc_possible_linebreaks ulc_possible_linebreaks_v2 102 103 /* Choose the best line breaks, assuming the uc_width function. 104 The string is s[0..n-1]. The maximum number of columns per line is given 105 as WIDTH. The starting column of the string is given as START_COLUMN. 106 If the algorithm shall keep room after the last piece, they can be given 107 as AT_END_COLUMNS. 108 o is an optional override; if o[i] != UC_BREAK_UNDEFINED, o[i] takes 109 precedence over p[i] as returned by the *_possible_linebreaks function. 110 The given ENCODING is used for disambiguating widths in uc_width. 111 Return the column after the end of the string, and store the result at 112 p[0..n-1]. 113 */ 114 extern int 115 u8_width_linebreaks (const uint8_t *s, size_t n, int width, 116 int start_column, int at_end_columns, 117 const char *o, const char *encoding, 118 char *_UC_RESTRICT p); 119 extern int 120 u8_width_linebreaks_v2 (const uint8_t *s, size_t n, int width, 121 int start_column, int at_end_columns, 122 const char *o, const char *encoding, 123 char *_UC_RESTRICT p); 124 #define u8_width_linebreaks u8_width_linebreaks_v2 125 126 extern int 127 u16_width_linebreaks (const uint16_t *s, size_t n, int width, 128 int start_column, int at_end_columns, 129 const char *o, const char *encoding, 130 char *_UC_RESTRICT p); 131 extern int 132 u16_width_linebreaks_v2 (const uint16_t *s, size_t n, int width, 133 int start_column, int at_end_columns, 134 const char *o, const char *encoding, 135 char *_UC_RESTRICT p); 136 #define u16_width_linebreaks u16_width_linebreaks_v2 137 138 extern int 139 u32_width_linebreaks (const uint32_t *s, size_t n, int width, 140 int start_column, int at_end_columns, 141 const char *o, const char *encoding, 142 char *_UC_RESTRICT p); 143 extern int 144 u32_width_linebreaks_v2 (const uint32_t *s, size_t n, int width, 145 int start_column, int at_end_columns, 146 const char *o, const char *encoding, 147 char *_UC_RESTRICT p); 148 #define u32_width_linebreaks u32_width_linebreaks_v2 149 150 extern int 151 ulc_width_linebreaks (const char *s, size_t n, int width, 152 int start_column, int at_end_columns, 153 const char *o, const char *encoding, 154 char *_UC_RESTRICT p); 155 extern int 156 ulc_width_linebreaks_v2 (const char *s, size_t n, int width, 157 int start_column, int at_end_columns, 158 const char *o, const char *encoding, 159 char *_UC_RESTRICT p); 160 #define ulc_width_linebreaks ulc_width_linebreaks_v2 161 162 163 #ifdef __cplusplus 164 } 165 #endif 166 167 168 #endif /* _UNILBRK_H */