1 /* linebreak.h - line breaking of Unicode strings
2 Copyright (C) 2001-2003 Free Software Foundation, Inc.
3 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 /* These functions are locale dependent. The encoding argument identifies
29 the encoding (e.g. "ISO-8859-2" for Polish). */
31 /* Return the encoding of the current locale. */
32 extern const char * locale_charset (void);
34 /* Determine number of column positions required for UC. */
35 extern int uc_width (unsigned int uc
, const char *encoding
);
37 /* Determine number of column positions required for first N units
38 (or fewer if S ends before this) in S. */
39 extern int u8_width (const unsigned char *s
, size_t n
, const char *encoding
);
40 extern int u16_width (const unsigned short *s
, size_t n
, const char *encoding
);
41 extern int u32_width (const unsigned int *s
, size_t n
, const char *encoding
);
54 /* Determine the line break points in S, and store the result at p[0..n-1].
55 p[i] = UC_BREAK_MANDATORY means that s[i] is a line break character.
56 p[i] = UC_BREAK_POSSIBLE means that a line break may be inserted between
58 p[i] = UC_BREAK_HYPHENATION means that a hyphen and a line break may be
59 inserted between s[i-1] and s[i]. But beware of language dependent
61 p[i] = UC_BREAK_PROHIBITED means that s[i-1] and s[i] must not be separated.
63 extern void u8_possible_linebreaks (const unsigned char *s
, size_t n
,
66 extern void u16_possible_linebreaks (const unsigned short *s
, size_t n
,
69 extern void u32_possible_linebreaks (const unsigned int *s
, size_t n
,
72 extern void mbs_possible_linebreaks (const char *s
, size_t n
,
76 /* Choose the best line breaks, assuming the uc_width function.
77 Return the column after the end of the string.
78 o is an optional override; if o[i] != UC_BREAK_UNDEFINED, o[i] takes
79 precedence over p[i] as returned by the *_possible_linebreaks function.
82 u8_width_linebreaks (const unsigned char *s
, size_t n
,
83 int width
, int start_column
, int at_end_columns
,
84 const char *o
, const char *encoding
,
87 u16_width_linebreaks (const unsigned short *s
, size_t n
,
88 int width
, int start_column
, int at_end_columns
,
89 const char *o
, const char *encoding
,
92 u32_width_linebreaks (const unsigned int *s
, size_t n
,
93 int width
, int start_column
, int at_end_columns
,
94 const char *o
, const char *encoding
,
97 mbs_width_linebreaks (const char *s
, size_t n
,
98 int width
, int start_column
, int at_end_columns
,
99 const char *o
, const char *encoding
,
103 #endif /* _LINEBREAK_H */