1/* Display width functions.
2   Copyright (C) 2001-2002, 2005 Free Software Foundation, Inc.
3
4   This program is free software; you can redistribute it and/or modify it
5   under the terms of the GNU Library General Public License as published
6   by the Free Software Foundation; either version 2, or (at your option)
7   any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   Library General Public License for more details.
13
14   You should have received a copy of the GNU Library General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17   USA.  */
18
19#ifndef _UNIWIDTH_H
20#define _UNIWIDTH_H
21
22#include "unitypes.h"
23
24/* Get size_t.  */
25#include <stddef.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31
32/* Display width.  */
33
34/* These functions are locale dependent.  The encoding argument identifies
35   the encoding (e.g. "ISO-8859-2" for Polish).  */
36
37/* Return the encoding of the current locale.  */
38extern const char *
39       locale_charset (void);
40
41/* Determine number of column positions required for UC.  */
42extern int
43       uc_width (ucs4_t uc, const char *encoding);
44
45/* Determine number of column positions required for first N units
46   (or fewer if S ends before this) in S.  */
47extern int
48       u8_width (const uint8_t *s, size_t n, const char *encoding);
49extern int
50       u16_width (const uint16_t *s, size_t n, const char *encoding);
51extern int
52       u32_width (const uint32_t *s, size_t n, const char *encoding);
53
54/* Determine number of column positions required for S.  */
55extern int
56       u8_strwidth (const uint8_t *s, const char *encoding);
57extern int
58       u16_strwidth (const uint16_t *s, const char *encoding);
59extern int
60       u32_strwidth (const uint32_t *s, const char *encoding);
61
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif /* _UNIWIDTH_H */
68