(root)/
gettext-0.22.4/
gettext-tools/
gnulib-lib/
unilbrk.in.h
       1  /* Line breaking of Unicode strings.
       2     Copyright (C) 2001-2003, 2005-2023 Free Software Foundation, Inc.
       3     Written by Bruno Haible <bruno@clisp.org>, 2001.
       4  
       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)
      13         any later version, or
      14       - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
      15  
      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
      20     for more details.
      21  
      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/>.  */
      25  
      26  #ifndef _UNILBRK_H
      27  #define _UNILBRK_H
      28  
      29  /* Get size_t.  */
      30  #include <stddef.h>
      31  
      32  #include "unitypes.h"
      33  
      34  /* Get locale_charset() declaration.  */
      35  #include "localcharset.h"
      36  
      37  
      38  #ifdef __cplusplus
      39  extern "C" {
      40  #endif
      41  
      42  
      43  /* These functions are locale dependent.  The encoding argument identifies
      44     the encoding (e.g. "ISO-8859-2" for Polish).  */
      45  
      46  
      47  /* Line breaking.  */
      48  
      49  enum
      50  {
      51    UC_BREAK_UNDEFINED,
      52    UC_BREAK_PROHIBITED,
      53    UC_BREAK_POSSIBLE,
      54    UC_BREAK_MANDATORY,
      55    UC_BREAK_HYPHENATION,
      56    UC_BREAK_CR_BEFORE_LF /* only used in _v2 or later */
      57  };
      58  
      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
      64            s[i-1] and s[i].
      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
      67            hyphenation rules.
      68     p[i] = UC_BREAK_PROHIBITED means that s[i-1] and s[i] must not be separated.
      69   */
      70  extern void
      71         u8_possible_linebreaks (const uint8_t *s, size_t n,
      72                                 const char *encoding, char *_UC_RESTRICT p);
      73  extern void
      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
      77  
      78  extern void
      79         u16_possible_linebreaks (const uint16_t *s, size_t n,
      80                                  const char *encoding, char *_UC_RESTRICT p);
      81  extern void
      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
      85  
      86  extern void
      87         u32_possible_linebreaks (const uint32_t *s, size_t n,
      88                                  const char *encoding, char *_UC_RESTRICT p);
      89  extern void
      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
      93  
      94  extern void
      95         ulc_possible_linebreaks (const char *s, size_t n,
      96                                  const char *encoding, char *_UC_RESTRICT p);
      97  extern void
      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
     101  
     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
     106     as AT_END_COLUMNS.
     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
     111     p[0..n-1].
     112   */
     113  extern int
     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);
     118  extern int
     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
     124  
     125  extern int
     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);
     130  extern int
     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
     136  
     137  extern int
     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);
     142  extern int
     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
     148  
     149  extern int
     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);
     154  extern int
     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
     160  
     161  
     162  #ifdef __cplusplus
     163  }
     164  #endif
     165  
     166  
     167  #endif /* _UNILBRK_H */