1/* Line breaking of Unicode strings. 2 Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc. 3 Written by Bruno Haible <bruno@clisp.org>, 2001. 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 _UNILBRK_H 19#define _UNILBRK_H 20 21/* Get size_t. */ 22#include <stddef.h> 23 24#include "unitypes.h" 25 26/* Get locale_charset() declaration. */ 27#include <unistring/localcharset.h> 28 29 30#ifdef __cplusplus 31extern "C" { 32#endif 33 34 35/* These functions are locale dependent. The encoding argument identifies 36 the encoding (e.g. "ISO-8859-2" for Polish). */ 37 38 39/* Line breaking. */ 40 41enum 42{ 43 UC_BREAK_UNDEFINED, 44 UC_BREAK_PROHIBITED, 45 UC_BREAK_POSSIBLE, 46 UC_BREAK_MANDATORY, 47 UC_BREAK_HYPHENATION 48}; 49 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. 58 */ 59extern void 60 u8_possible_linebreaks (const uint8_t *s, size_t n, 61 const char *encoding, char *p); 62extern void 63 u16_possible_linebreaks (const uint16_t *s, size_t n, 64 const char *encoding, char *p); 65extern void 66 u32_possible_linebreaks (const uint32_t *s, size_t n, 67 const char *encoding, char *p); 68extern void 69 ulc_possible_linebreaks (const char *s, size_t n, 70 const char *encoding, char *p); 71 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]. 82 */ 83extern 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); 88extern 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); 93extern 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); 98extern 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); 103 104 105#ifdef __cplusplus 106} 107#endif 108 109 110#endif /* _UNILBRK_H */ 111